title: Java Regex: Match any word from pattern
body: <p>I'm trying to implement a search function.
  The user types a phrase and I want to match any word from the phrase and the phrase itself in an array of strings.
  The problem is that the phrase is stored in a variable, so the <code>Pattern.compile</code> method won't interpret its special characters.</p>
  
  <p>I'm using the following flags for the compile method:</p>
  
  <blockquote>
    <p>Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.LITERAL |
    Pattern.MULTILINE</p>
  </blockquote>
  
  <p>How could I achieve the desired result?</p>
  
  <p>Thanks in advance.</p>
  
  <p>edit:
  For example, the phrase:</p>
  
  <blockquote>
    <p>"Dog cats donuts"</p>
  </blockquote>
  
  <p>would result in the pattern:</p>
  
  <blockquote>
    <p>Dogs | cats | donuts | Dogs cats donuts</p>
  </blockquote>