I am very familiar with Perl regular expression and have used
org.apache.regexp.RE package for a little while but only for simple
matching. How do I match a word in a regular expression? According to
the RE javadocs:
\w Matches a "word" character (alphanumeric plus "_")
So could someone give me some example Java code? I am analyzing a file
path and want to grab the first directory name (ex. "/dir1/dir2/dir3").
Like:
String path = "/dir1/dir2/dir3";
RE exp = new RE ("^/([\w])/.*");
boolean matched = exp.match(path);
String insideParens = exp .getParen(1);
The compiler complains about \w being invalid. Do I have to put the \w
inside of colons or something? Or not include the braces?
Also, I know I need to apply the pattern to my path String but do I have
to use the match method or are there other ways of doing it?
Any help would be appreciated.
Brian
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>