The Pattern.COMMENTS flag has nothing to do with comments in Java code - it's to allow comments and whitespace
in your regular expression, which can be used to improve readability. E.g. the pattern
(\w+)\s+(\w+)
could be written
(\w+) # first name
\s+ # space(s)
(\w+) # last name
If you compile with Pattern.COMMENTS, the regex compiler will ignore the newlines, blanks, and comments indicated by #, converting it back to
(\w+)\s+(\w+)
That may not seem incredibly useful here, but imagine that the pattern had been somewhat more complex - the ability to insert whiteapce and comments can be very nice indeed. Though it's more effective in some other languages like Perl, which allow you to write a multi-line pattern expression withoutspecial escape sequesnces like "\\" and "\n". Oh well...
As for your general problem - yeah, I agree with EFH. (Always a good idea.)
[ November 20, 2004: Message edited by: Jim Yingst ]