Skip to content

Instantly share code, notes, and snippets.

@tom--
Created August 7, 2012 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tom--/3288254 to your computer and use it in GitHub Desktop.
Save tom--/3288254 to your computer and use it in GitHub Desktop.
recursive matching braces to a limited depth
<?php
preg_match(
'%'
. preg_quote($marker, '%')
. '\{
(?:[^{}]*\{
(?:[^{}]*\{
(?:[^{}]*\{
(?:[^{}]*\{
(?:[^{}]*\{
[^{}]*
\}[^{}]*)*
\}[^{}]*)*
\}[^{}]*)*
\}[^{}]*)*
\}[^{}]*)
\}'
. '%x',
$subject,
$matches
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment