I am having a hard time trying to figure out this regex pattern. I want to replace all non-numeric characters in a string except for certain alpha character patterns.
For example i am trying:
string str = "The sky is blue 323.05 lnp days of the year";
str = Regex.Replace(str, "(^blue|lnp|days)[^.0-9]", "", RegexOptions.IgnoreCase);
I would like it to return:
"blue 323.05 lnp days"
but I can't figure out how to get it to match the entire character pattern in the expression.
\b((?!blue|lnp|days)[^.0-9 ]+?)\b
– Code Maniac(\b(?:blue|lnp|days)\b|\d*\.?\d+)|[^\d\s]
and replace with group 1 regex101.com/r/rZfCXJ/1 – The fourth bird