title: Javascript : Extract words starting with specific character in a string
body: <p>I'm having this string : </p>
  
  <pre><code>Hey I love #apple and #orange and also #banana
  </code></pre>
  
  <p>I would like to extract every words that start with the <code>#</code> symbol.</p>
  
  <p>Currently I'm achieving it with this code :</p>
  
  <pre><code>var last = 0;
  var n = 0;
  var str = "Hey I love #apple and #orange and also #banana";
  do{
      n = str.indexOf("#", last);
      if(n != -1){
          //The code found the # char at position 'n'
          last = n+1; //saving the last found position for next loop
  
          //I'm using this to find the end of the word
          var suffixArr = [' ', '#'];
          var e = -1;
          for(var i = 0; i &lt; suffixArr.length;i++){
              if(str.indexOf(suffixArr[i], n) != -1){
                 e = str.indexOf(suffixArr[i], n+1);
                 break;
              }
          }
          if(e == -1){
              //Here it could no find banana because there isn't any white space or # after
              e = str.length; //this is the only possibility i've found
          }
  
          //extracting the word from the string
          var word = str.substr(n+1, (e-1)-n);
     }
  }
  while (n != -1);
  </code></pre>
  
  <p>How can I manage to find words starting with # and with <code>a-Z characters</code> only. If for example I have <code>#apple!</code> i should be able to extract <code>apple</code>
  And also, as I mentionned in the code, how do I manage to get the word if it appears at the end of the string</p>