PCRE: Find matching brace for code block
问题 Is there a way for PCRE regular expressions to count how many occurrences of a character it encounters (n), and to stop searching after it has found n occurrences of another character (specifically { and } ). This is to grab code blocks (which may or may not have code blocks nested inside them). If it makes it simpler, the input will be a single-line string, with the only characters other than braces are digits, colons and commas. The input must pass the following criteria before code blocks