Regex for a number followed by a word
问题 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. Here are the conditions in a form of example: 123 dollars => Catch the '123' and the 'dollars'. foo bar 0.2 dollars => 0.2 and dollars foo bar.5 dollar => 5 and dollar (notice the dot before 5) foo bar.5.6 dollar => 5.6 and dollar foo bar.5.6.7 dollar => skip (could be only 0 or 1 dot) foo bar5 dollar => skip foo bar 5dollar