in php I want to match the string: name if it was contained between (( ))
I tried:
/\(\((.*)\)\)/U
and it works perfectly but if the string was between three brackets it fai开发者_StackOverflow中文版l so (((name))) or (((name)) doens't work
how to write a regexp for that?
Thanks a lot for your help
In a regular expression you can quantify the number of times something appears with {min,max}
following the token. ie.
\({2,}(.*?)\){2,}
This matches 2 or more ( on the left and 2 or more ) on the right. Leaving the 2nd value of {min,max}
blank means "min matches to infinite matches" so it will match ((((((((string))) or any variation as long as there are 2+ parens on each side.
\({2,}(.*?)\){2,}
Will match greater than 2 leading or trailing brackets.
精彩评论