I am not great with regular expressions. I am looking to find if a string contains \"( ),[ ], { }\". Note, I am not looking for the contents in the actual ( ), just to see if
Use alternatives with a non-greedy match:
/\(.*?\)|\{.*?\}|\[.*?\]/
Without those question marks, the patterns .*
would be "greedy", eg scanning "abc(def)ehi(jkl)mno" would find only one match of "(def)ehi(jkl)" (the .*
would gobble up everything to the last close bracket), but using non-greedy .*?
you would get two matches "(def)" and "(jkl)" as you would want.