Hello, I'm trying to create a regular expression that will reformat a string. basically I only want to allow a-z A-Z 0-9 a space and an "x" so if there are any other char found it should remove it from the string Does anyone know the best way to do this besides just looping through the string and removing the unwanted char
just a variable somewhere. I figured it out, here is the code just in case anyone wants to use it. string pattern = @"[^A-Za-z0-9\s@.]"; Regex rgx = new Regex(pattern); string inputStr = "2o3423u 09809283 asdjflj 39!@#$%^@#$099248"; string outputStr = rgx.Replace(inputStr, ""); I changed the code to allow alphanumeric, space, dot, and @