Search code examples
c#regexparentheses

Use Regex to find parentheses


I need to find if a string any kind of parentheses ( ) { } [ ]. These parentheses can be in any order and can appear nay where in the string. How to do that in C# using RegEx?


Solution

  • You can try using this for the regex pattern:

    string pattern = @"[\(\)\[\]\{\}]+$";
    

    Also here is a link to another question to check for alpha numeric and special characters.