I am trying to write a Regex
to stop a use entering invalid characters into a postcode field.
from this link I manged to exclude all "Non-word" characters like so.
Regex regex = new Regex(@"[\W_]+");
string cleanText = regex.Replace(messyText, "").ToUpper();
But this also excludes the "Space" characters.
I am sure this is possible but I find regex very confusing!
Can someone help out with an explanation of the regex pattern used?