c# - Simple Numeric Regex not working -
i strip string
have numeric values , 1 decimal point.... wrong regex?
string test = "1e2e3.e4"; var s = regex.replace(test, "^\\d*\\.\\d*$", "");
what you're doing striping away decimal number, try instead:
regex.replace(test, "[^\\d.]", "");
if want keep 1 dot, first need determine dot want keep if there's many of them.
update: assuming you'd want keep first or last dot, use string.indexof
or string.lastindexof
split string , use:
regex.replace(test, "\\d", "");
on each of resulting strings. potentially slower not using regex in matt hamilton answer tough.
Comments
Post a Comment