title: Match multiline text using regular expression
body: <p>I am trying to match a multi line text using java. When I use the <code>Pattern</code> class with the <code>Pattern.MULTILINE</code> modifier, I am able to match, but I am not able to do so with <code>(?m).</code></p>
  
  <p>The same pattern with <code>(?m)</code> and using <code>String.matches</code> does not seem to work.</p>
  
  <p>I am sure I am missing something, but no idea what. Am not very good at regular expressions.</p>
  
  <p>This is what I tried</p>
  
  <pre><code>String test = "User Comments: This is \t a\ta \n test \n\n message \n";
  
  String pattern1 = "User Comments: (\\W)*(\\S)*";
  Pattern p = Pattern.compile(pattern1, Pattern.MULTILINE);
  System.out.println(p.matcher(test).find());  //true
  
  String pattern2 = "(?m)User Comments: (\\W)*(\\S)*";
  System.out.println(test.matches(pattern2));  //false - why?
  </code></pre>