title: Regex for matching a string literal in Java?
body: <p>I have an array of regular expressions strings. One of them must match any strings found in a given java file.</p>
  
  <p>This is the regex string I have so far: <code>"(\").*[^\"].*(\")"</code></p>
  
  <p>However, the string <code>"Hello\"good day"</code> is rejected even though the quotation mark inside the string is escaped. I think what I have immediately rejects the string literal when it finds a quotation mark inside regardless of whether it is escaped or not. I need it to accept string literals with escaped quotes but it should reject <code>"Hello"Good day"</code>.</p>
  
  <pre><code>  Pattern regex = Pattern.compile("(\").*[^\"].*(\")", Pattern.DOTALL);
    Matcher matcher = regex.matcher("Hello\"good day");
    matcher.find(0); //false
  </code></pre>