title: Regex filtering arrays javascript
body: <p>So I have a regex:</p>
  <pre><code>  const [keyword, setKeyword] = useState('')
    const pattern = new RegExp('\\b' + filterkeyword.replace(/[^a-zA-Z0-9 ]/g, &quot;&quot;), 'i')
  </code></pre>
  <p>An item in the products array would look something like this:</p>
  <pre><code>{
   name: 'Men's Shirts',
   price: 123,
   sale: 30,
   ...
  }
  </code></pre>
  <p>basically, whenever a user types on an input, this keyword is being sent. I am then using</p>
  <pre><code>products.filter(x=&gt; pattern.test(x.name)).map(product=&gt; {return &lt;Product /&gt;})
  </code></pre>
  <p>The issue I'm having here is that if the name of the product is &quot;Men's Shirts&quot; or &quot;Women's Shirts&quot; or anything that contains a {'}, the filter won't work anymore.
  Any idea how I can fix this issue?</p>