I have the following file contents and I'm trying to match a reg explained below:
-- file.txt (doesn't match multi-line) -- test On blah more blah wrote: --------------- If I read the file contents from above to a String and try to match the "On...wrote:" part I cannot get a match:
// String text = <file contents from above> Pattern PATTERN = Pattern.compile("^(On\\s(.+)wrote:)$", Pattern.MULTILINE); Matcher m = PATTERN.matcher(text); if (m.find()) { System.out.println("Never gets HERE???"); } The above regex works fine if the contents of the file are on one line:
-- file2.txt (matches on single line) -- test On blah more blah wrote: On blah more blah wrote: --------------- How do I get the multiline to work and the single line all in one regex (or two for that matter)? Thx!