Larry Li

Greenhorn
+ Follow
since Nov 25, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Larry Li

Hi Henry,

I've been thinking of this for days and finally used the similar solution as you provided. I agree with you that this is not likely done in one single expression.

Thank you very much anyway.

Larry
17 years ago

To answer your question... To match the above line (with the three fields), you can use "^\\S{1,10}\\s+\\S{1,5}\\s+\\S{1,5}\\s*$" as the regular expression.



I don't think this pattern could work, "abc##abc##abc#" for instance, matches this pattern, but does not follow the format, which requires the first field fed with 7 spaces.

Thanks,

Larry
17 years ago
Thanks for your reply!

The requirement is to check if each line of a text file follows some specific format or not.

For example,
A line of that file requires the first field contains 10 characters, and the second field contains 5, and the third field contains 5. A valid line should look like this: (# for spaces)
field1####f2###f3###

I hope to use a single regex pattern to represent this format, so to simplify the check.



It has to be a maximum of ten characters, and include enough whitespace padding to make it 15 characters? That's unpossible!



Sorry that this was a mistake. It should be a maximum of 10 characters, and if the string (no space in it) is less than 10, padding it to 10 characters, not 15.
[ April 24, 2006: Message edited by: Larry Li ]
17 years ago
Dear,

I have to use the Java regex to check whether a String conform to the below format:

1. Fix length: 10;
2. Start with a word which is composed of non-space characters (\S);
3. If the word is shorter than 15, filled with white spaces (\s) to 15;

For example,
"ABCDEFGHI " is conform to this format.
"ABC DEFGHI " is not.

Could anybody help me work out a regular expression to check it?

Thank you very much in advance!

Larry

[Bear edit: removed "urget" from title]
[ April 24, 2006: Message edited by: Bear Bibeault ]
17 years ago
Thx Mark.
I think I need to look through more threads about lock implementation, unreference and WeakHashMap are new to me, no matter which method I finally use, I will learn both of them.

3. In local mode there should be no locking.


update(int recNo, long cookie), so in alone mode, I can pass a predefined cookie value to indicate that, and update without check lockMap, is that right?
Hi,all.
My assignment is URLyBird 1.1.1, it's an early version of new ones.I got it last April, I put it off about half a year and want to finish it now, i've read lots of threads on many topics, they're really helpful, thank you all.
Here are some questions that still confused me, thanks any help or comments.
1. about lock-delete-unlock,how to avoid RecordNotFoundException in unlock method.
I've read this thread:
https://coderanch.com/t/184241/java-developer-SCJD/certification/NX-URLyBird-lock-delete-unlock
Vlad suggested to do unlock in delete course, I'm not quite agree with that,I think "each method should do his own job",it is not proper for delete() to unlock a record, and even we can do this, how can a delete() throw a SecurityException(unlock check it)?
2. about locking, I now use a HashMap(Integer(recNo),Long(lockCookie)) to store locked records, but after read some articles on this topic, I found it can do nothing when a client crash occurs. But I don't know how to use a weakHashMap, because both recNo and lockCookie have to be stored.
3. In my implementation, both stand alone mode and server mode are involved in locking course, is this permitted? Or the alone mode need to by pass the entire locking course?
Thx for any reply
I prefer to use ComboBox for criteria search on client side. The names and locations that the user could search are only selected from the list, "any" is supported. So we get it, "Exactly match" is controlled by items we add to the ComboBox.
But the problem about extending the interface is still there: I want to add another method:
getDistinctColumnValue()
to get all search items.
TQ, I'm not quite agree with it.
I think a hotel with two same room is possible.
Yes, a room number is the best identity, but without it, a room can still be booked, when a customer comes, the waiter takes him to one of these rooms randomly. Looks strange, but possible.
Chan, when read the instruction doc for the first time, I had the same view. But there aren't any specific instruction that mention it, so "may be" couldn't do any help. And I think there possibly two same rooms in a hotel, that is to say, with same hotel name and location.
Appreciate your comments.Keep in touch
Larry.

I can't find any "unique like" ideas according to code above, neither in other part of the instruction doc.
Thx, Mark.
I got your idea, it's really helpful,but not in the Hotel Booking assignment.
I think two record can be completely the same before they are booked by someone after when they get a unique customer id.
Let's take a look at the columns:
Hotel Name,City,Maximum occupancy of this room,
Is the room smoking or non-smoking,
Price per night,Date available,Customer holding this record;
Before book course, it's usual for the hotel which has two same rooms.
So when find() could get same return values, I think it doesn't mean we couldn't add another same room.
Let's back to the original question, In my assignment the create method takes String[] data as input param, we don't know which column is the key, how could we judge when to throw DuplicateKeyException in the implementation? Or just leave it there without doing anything?
I got this problem after finished create method, and surprisingly found no way to throw this exception.
In this database, we take recNo as the access key, whether reuse deleted record's space or not, we can avoid put two live record in to the some place, so no DuplicateKeyException .
Appreciate any comment.
Larry
Thx,Gaunt.
I get it, I will do it at client in local mode but not server mode. For I don't think a remote client should have any rights to modify the server configuration.
Larry.
Thx.
To the second question, we have a config file both in client and server, and do we need to have a GUI to modify it?
If yes, it's works of the server but not the client, if no ,what does "all configuration must be done via a GUI" mean?