title: How to use regex pattern \W in javascript
body: <p>I have a regex pattern for matching special characters</p>
  <pre><code>ptr = /\W|_/g 
  </code></pre>
  <p>It's working fine for every special character except <code>*</code></p>
  <p>Here is the my testing results</p>
  <pre><code>ptr = /\W|_/g
  ptr.test('vbk_')
  true
  ptr.test('vbk*')
  false
  ptr.test(&quot;Select * from user&quot;)
  true
  ptr.test(&quot;Select * from user&quot;)
  true
  ptr.test(&quot;Select * from user&quot;)
  true
  ptr.test('vbk*')
  false
  </code></pre>
  <p>When I remove global(<code>g</code>) from the pattern it seems working fine can anyone suggest me why this happening</p>
  <p>Here are my testing results:</p>
  <pre><code>ptr = /\W|_/
  ptr.test('vbk*')
  true
  ptr.test('vbk')
  false
  ptr.test('Select * from user')
  true
  </code></pre>