G
Glenn Meter
I'm trying to use the regex package to match strings at the beginning
of lines within files. However, it looks like ^ is only matching on
items at the start of the string, not at the start of a line.
This sets b to true, with m.start() returning 0 [the beginning of text]:
Pattern p = Pattern.compile("^foo");
Matcher m = p.matcher("foo\nmatch bar\n");
boolean b = m.find();
This leaves b as false:
Pattern p = Pattern.compile("^match");
Matcher m = p.matcher("foo\nmatch bar\n");
boolean b = m.find();
Since the top test succeeds, it looks like it's taking '^' as a
boundary marker instead of the "not this character" marker.
The fact that RegexTestHarness only checks one line at a time isn't
giving me great confidence that multi-line input was thoroughly tested.
Any clues would be greatly appreciated.
Thanks,
Glenn
of lines within files. However, it looks like ^ is only matching on
items at the start of the string, not at the start of a line.
This sets b to true, with m.start() returning 0 [the beginning of text]:
Pattern p = Pattern.compile("^foo");
Matcher m = p.matcher("foo\nmatch bar\n");
boolean b = m.find();
This leaves b as false:
Pattern p = Pattern.compile("^match");
Matcher m = p.matcher("foo\nmatch bar\n");
boolean b = m.find();
Since the top test succeeds, it looks like it's taking '^' as a
boundary marker instead of the "not this character" marker.
The fact that RegexTestHarness only checks one line at a time isn't
giving me great confidence that multi-line input was thoroughly tested.
Any clues would be greatly appreciated.
Thanks,
Glenn