title: Efficient way to check if an input string contains any punctuation from a string of punctuations
body: <p>I am working on a logic to detect if an input string contains any punctuation from a string of punctuations. </p>
  
  <pre><code>public boolean detectAnyPunctuation(String input, String punctuationArray){}
  </code></pre>
  
  <p>The function should return true of any of the punctuation from punctuation array is found in input string. Punctuation Array is not fixed. It could be changed with each function call. Input string cannot exceed 1000 chars.</p>
  
  <p>I am thinking of converting a punctuation array to a char array and then running a loop over the char array to check for character in input string. 
  Time complexity for this would be O(MN) where m are characters in punctuation array and N in input array (worst case). </p>
  
  <p>Finally I implemented using regex as below, </p>
  
  <pre><code>public static boolean detectPunctuations(String in, String pu){ 
  String puQ = “[” + pu + “]”; 
  Pattern pattern = Pattern.compile(puQ); 
  Matcher m = pattern.matcher(in); 
  return m.find(); 
  }
  </code></pre>
  
  <p><strong>EDIT:</strong>
  Now I am trying to find if it contains all punctuations from punctuation string or not. It should return true only if all punctuations from punctuation string appear in the input string. Any inputs for this one please ?</p>