title: Regex for a number followed by a word
body: <p>In JavaScript, what would be the regular expression for a number followed by a word? I need to catch the number AND the word and replace them both after some calculation.</p>
  
  <p>Here are the conditions in a form of example:</p>
  
  <pre><code>123 dollars =&gt; Catch the '123' and the 'dollars'.
  foo bar 0.2 dollars =&gt; 0.2 and dollars
  foo bar.5 dollar =&gt; 5 and dollar (notice the dot before 5)
  foo bar.5.6 dollar =&gt; 5.6 and dollar
  foo bar.5.6.7 dollar =&gt; skip (could be only 0 or 1 dot)
  foo bar5 dollar =&gt; skip
  foo bar 5dollar =&gt; 5 and dollar
  5dollar =&gt; 5 and dollar
  foo bar5dollar =&gt; skip
  </code></pre>
  
  <ul>
  <li>Of course 123.555, 0.365, 5454.1 are numbers too.</li>
  <li><p>For making things simpler the word is a specific one (e.g
  dollar|euro|yen).</p></li>
  <li><p>OK.. Thank you all... Here is the basic function I made so far:</p>
  
  <p>var text = "foo bar 15 dollars. bla bla..";
  var currencies = {
      dollars: 0.795
  };</p>
  
  <p>document.write(text.replace(/\b((?:\d+.)?\d+) *([a-zA-Z]+)/, function(a,b,c){
      return currencies[c] ? b * currencies[c] + ' euros' : a;
      }
  ));</p></li>
  </ul>