Hay, i have a string like this:
v8gn5.8gnr4nggb58gng.g95h58g.n48fn49t.t8t8t57
I want to strip out all the characters leaving just numbers (and .s)
Any ideas how to do this? Is there a function prebuilt?
thanks
To remove all characters except numbers in javascript, call the replace() method, passing it a regular expression that matches all non-number characters and replace them with an empty string. The replace method returns a new string with some or all of the matches replaced.
Notes: (1) You can type the formula =EXTRACTNUMBERS(A2,TRUE) into selected cell directly, and then drag the Fill handle to the range as you need. (2) This EXTRACTNUMBERS function will also remove all kinds of characters except the numeric characters.
Using 'str. replace() , we can replace a specific character. If we want to remove that specific character, replace that character with an empty string. The str. replace() method will replace all occurrences of the specific character mentioned.
$str = preg_replace('/[^0-9.]+/', '', $str);
replace substrings that do not consist of digits or . with nothing.
preg_replace('/[^0-9.]/', '', $string);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With