This will work for prime numbers containing 0 - 9.
var my_string = $('a#my_link').text().replace(/[0-9]+/, 'replacement');
If you need to match more complex numbers, such as decimal and negative numbers, then this will work:
var my_string = $('a#my_link').text().replace(/-?[0-9]*\.?[0-9]+/, 'replacement');
If you need to match even harder things, like exponential notation or numbers with commas, you need to change the regular expression accordingly - how you do it will depend on how strictly you want to check.
Jhong
source share