title: Converting a dynamic string variable to a regex expression for string.match()?
body: <p>I have a string variable being passed down to the method check() called 'letters' (Say). The string is therefore going to be dynamic.</p>
  
  <p>The method requires checking if the words passed separately in an arraylist contain only the characters contain within 'letters'.</p>
  
  <p>I have the following within my loop, with the word string changing each time as the loop iterates through the array.</p>
  
  <pre><code>word = wordArray.get(i);
  
  if ((word.length() &lt;= letters.length()) &amp;&amp; (word.matches(letters))
  {
      // Do something.
  }
  </code></pre>
  
  <p>The string.matches() seems the way to go, however I'm having issues figuring out how I can use the letters string variable as an expression which the matches used, given the above code does not work.</p>
  
  <p>My thoughts are that I may need to add certain expression characters, or perhaps escape the letters string? (I've played around with this though with no luck) Could anyone advise as to how I can ensure the word can only contain characters from the string variable 'letters'?</p>
  
  <p>Thanks</p>