title: How to ignore whitespace in regular expression matching
body: <p>I have a list with the following keywords:</p>
  <pre><code>[&quot;mark&quot;, &quot;anthony&quot;, &quot;joseph smith&quot;, &quot;michael&quot;,...]
  </code></pre>
  <p>I want to create a regex delimited by a <code>|</code> so that I have something like:</p>
  <pre><code>mark|anthony|joseph smith|michael
  </code></pre>
  <p>I'm doing this like...</p>
  <pre><code>StringJoiner regex = new StringJoiner(&quot;|&quot;);
  words.forEach(regex::add);
  String matcher = regex.toString();
  </code></pre>
  <p>However there is an issue when I use this approach. If I have the following strings I want to match on:</p>
  <pre><code>&quot;josephsmith is unique&quot;
  &quot;joseph smith is unique&quot;
  </code></pre>
  <p>I want both scenarios to match. What can I add to my code to ignore the whitespace?</p>
  <p>I was thinking to maybe use <code>replace(&quot; &quot;, ...)</code> on every keyword to replace the spaces with some sort of regex but I'm not sure how that would work with escaping characters.</p>