I have a Regex
to remove non-numerical characters prior to parsing a decimal number.
I use the following code
Regex.Replace(myStr, "[^0-9.]", "");
Now this works for decimal numbers, but it removes the "sign" character, i.e. output for "A16.1" and "A-16.1" returns both "16.1"...
Using following edited version seems to work
Regex.Replace(myStr, "[^-0-9.]", "");
But being unfamiliar with Regex, can an experienced user confirm this is the right expression...?
I suggest
pattern, i.e. removing decimals will be
explanation:
In case you want to obtain (not remove) numbers, use
Matches
:the outcome is