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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -