title: Java String.matches regex with OR pipe
body: <p>I am trying to make the following match, but it is not returning true as I would expect:</p>
  
  <pre><code>String attrs = "id|fullname|email|title";
  String regex = "fullname|email";
  return attrs.matches(regex);
  </code></pre>
  
  <p>Instead it returns false.</p>
  
  <p>Why is this? I expect the | pipe in attrs to be interpreted literally as an ASCII character, and the | pipe in regex to be interpreted according to regular expressions (i.e. OR).</p>
  
  <p>The reason I ask is because I am writing an application where I let the user set the attributes in the format attr1|attr2|attr3|..., and I want to verify his/her input by matching it against the possible attribute values: attr1|attr2|attr3|...|attr[n].</p>
  
  <p>Help appreciated,<br>
  ktm</p>
  
  <hr> 
  
  <p>Got it working by doing</p>
  
  <pre><code>String regex = "id.*|fullname.*|email.*|title.*";
  String attrs = "fullname|email";
  return attrs.matches(regex);
  </code></pre>