Java Reference
In-Depth Information
}
}
}
}
This program correctly matches the “combining accent” and rejects the other characters,
some of which, unfortunately, look like the accent on a printer, but are not considered “com-
bining accent” characters:
égal matches input égal
égal matches input e?gal
égal does not match input e?gal
égal does not match input e'gal
égal does not match input e´gal
For more details, see the character charts .
Matching Newlines in Text
Problem
You need to match newlines in text.
Solution
Use \n or \r .
See also the flags constant Pattern.MULTILINE , which makes newlines match as beginning-
of-line and end-of-line ( \^ and $ ).
Discussion
Though line-oriented tools from Unix such as sed and grep match regular expressions one
line at a time, not all tools do. The sam text editor from Bell Laboratories was the first inter-
active tool I know of to allow multiline regular expressions; the Perl scripting language fol-
lowed shortly after. In the Java API, the newline character by default has no special signific-
ance. The BufferedReader method readLine() normally strips out whichever newline
Search WWH ::




Custom Search