How to check for any special character in a string without removing the character

I want to use an if condition that checks to see if a string contains a special character… what regex syntax do i use to check for this?

try this below


hope to be helpful

this isnt working

Try this regex pattern: “%[^A-Za-z0-9]”

Adding more to @lena2505 's pattern, \s will take care of the spaces as well.

this will be your condition:
if System.Text.RegularExpressions.Regex.Match(text,“patter”).Success

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.