Sunday 29 December 2019

Java regex match same length groups

I want to match strings like
(()) - 2 open brackets, 2 closed brackets
but not strings like
()() - open and closed and then another opens and closses

(() - two opens, one closed



So more specific i want a regex like this



\({n}\){n}


n opened brackets followed by (same value for n, but n must be greedy) n closed brackets.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...