title: Tokenizing strings using regular expression in Javascript
body: <p>Suppose I've a long string containing newlines and tabs as:</p>
  
  <pre><code>var x = "This is a long string.\n\t This is another one on next line.";
  </code></pre>
  
  <p>So how can we split this string into tokens, using regular expression?</p>
  
  <p>I don't want to use <code>.split(' ')</code> because I want to learn Javascript's Regex. </p>
  
  <p>A more complicated string could be this:</p>
  
  <pre><code>var y = "This @is a #long $string. Alright, lets split this.";
  </code></pre>
  
  <p>Now I want to extract only the valid <em>words</em> out of this string, without special characters, and punctuation, i.e I want these:</p>
  
  <pre><code>var xwords = ["This", "is", "a", "long", "string", "This", "is", "another", "one", "on", "next", "line"];
  
  var ywords = ["This", "is", "a", "long", "string", "Alright", "lets", "split", "this"];
  </code></pre>