Find and get only number in string
javascript, regex
Solution
You're replacing only the first non-digit character with empty string. Try using:
var id = window.location.href.replace(/\D+/g, '' ); alert(id);
(Notice the "global" flag at the end of regex).
Problem
Please help me solve this strange situation: Here is code: The link is so - `www.blablabla.ru#3` The regex is so: ``` var id = window.location.href.replace(/\D/, '' ); alert(id); ``` The regular expression is correct - it must show only numbers ... but it's not showing numbers :-( Can you please advice me and provide some informations on how to get only numbers in the string ? Thanks