title: Regex matching the boundary of a word that may contain punctuation
body: <p>I am using regular expressions to manipulate a list of space-delimited strings. When a user wishes to delete a tag, the regex replaces the to-be-deleted tag with <code>null</code> and the system saves the new list. This ran into a snag when users started entering punctuation as part of the tag (valid use case). I started using regex escape when I realized punctuation was used:</p>
  
  <pre><code>RegExp.escape = function(s){
    return String(s).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&amp;');
  };
  </code></pre>
  
  <p>When coupled with my existing regex format (<code>\bTAGTODELETE\b</code>), this doesn't match in certain scenarios.</p>
  
  <p>Take the following example tag list: <code>thisisatest? other test test2 test? test?ing</code></p>
  
  <p>If I want to delete <code>test?</code> from the list, <code>\btest\?\b</code> matches <code>test?ing</code>. If I want to delete <code>thisisatest?</code>, <code>\bthisisatesttest\?\b</code> has 0 matches.</p>
  
  <p>I've tried a few iterations but each seems to have its own problems.</p>