Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

Regex help

Thread view: 
SpideyPKT - 06 Jan 2006 20:05 GMT
Help!

I'm trying to create a regex and I can't quite seem to get it right...

I'm trying to get several arguments out of a string which looks like:

args=['arg #1']
or
args=['arg #1', 'arg #2', 'arg #3']

I'd like to be able access the arguments via something like:
for(int i=1; i <= m.groupCount(); i++)
   arg[i] = m.group(i);

The closest pattern I've gotten is:
"args=\\[(?:\'(.*?)\',)*\\s*\'(.+)\'\\]"

My problem is that for a single argument, I get arg[1] = null and
arg[2] = "arg #1" and for 3 or more arguments i get arg[1] = arg #1 and
arg[2] = arg #2' , 'arg #3 so it has something to do with it greedily
grabbing the rest of the characters.

Any ideas???

Thanks in advance!
Brian
Roedy Green - 07 Jan 2006 20:11 GMT
>My problem is that for a single argument, I get arg[1] = null and
>arg[2] = "arg #1" and for 3 or more arguments i get arg[1] = arg #1 and
>arg[2] = arg #2' , 'arg #3 so it has something to do with it greedily
>grabbing the rest of the characters.
>
>Any ideas???

tackle it as multiple problems.

find an arglist.  Once you have that find the args, One you have that
process each arg.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.