3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = "@ ^([\\x20\\t]*)/\\*!\\* (?:[\\x20\\t]*(!?\\w*))? # Start with some indent, a comment with the special marker, then an optional name ((?:[^*]|\\*[^/])*) # Any amount of \"a character that isnt a star, or a star not followed by a / \\*/ # The comment end @mx"; $str = "use hafriedlander\Peg\Parser;\n\nclass FQL extends Parser\Basic\n{\n /*!* FQL\n Quote: !'\\''\"'\n Character: /[^\t\n\r\"]/\n Word: w:('\\\"' | Character)+\n function w(&\$res, \$sub) {\n if ( !isset(\$res['val']) ) \$res['val'] = '';\n \$res['val'] .= \$sub['text'];\n }\n FunctionName: w:/ \w+ /\n function w(&\$res, \$sub) {\n if ( !isset(\$res['val']) ) \$res['val'] = '';\n \$res['val'] .= \$sub['text'];\n }\n Connector: c:/ ((a|A)(n|N)(d|D))|((x|X)(o|O)(r|R))|((o|O)(r|R)) /\n function c(&\$res, \$sub) {\n \$res['val'] = strtolower(\$sub['text']);\n }\n Operand: o:/ !((h|H)(a|A)(s|S))|((h|H)(a|A)(s|S))|!((i|I)(n|N))|((i|I)(n|N))|!=|>=|<=|=|<|> /\n function o(&\$res, \$sub) {\n \$res['val'] = strtolower(\$sub['text']);\n }\n ValueAtom: > (Quote atom:Word Quote | emptyAtom:'\"\"') >\n function atom(&\$res, \$sub) {\n \$res['val'] = \$sub['val'];\n }\n function emptyAtom(&\$res, \$sub) {\n \$res['val'] = \"\";\n }\n ValueList: > '[' > atom:ValueAtom (> ',' > rest:ValueAtom)* > ']' >\n function atom(&\$res, \$sub) {\n \$res['val'] = [\$sub['val']];\n }\n function rest(&\$res, \$sub) {\n \$res['val'][] = \$sub['val'];\n }\n ControlAtom: > Quote '#' atom:Word Quote >\n function atom(&\$res, \$sub) {\n \$res['val'] = \$sub['val'];\n }\n ColumnAtom: > Quote > ':' atom:Word Quote >\n function atom(&\$res, \$sub) {\n \$res['val'] = \$sub['val'];\n }\n FunctionAtom: > fnc:FunctionName > '(' atom:ControlAtom (',' > params:ValueAtom >)* ')' >\n function atom(&\$res, \$sub) {\n \$res['val'] = \$sub['val'];\n }\n function fnc(&\$res, \$sub) {\n \$res['fnc'] = strtolower(\$sub['val']);\n \$res['params'] = [];\n }\n function params(&\$res, \$sub) {\n \$res['params'][] = \$sub['val'];\n }\n Assignment: (control:FunctionAtom | control:ControlAtom | control:ColumnAtom) operand:Operand (value:ValueList | value:ValueAtom)\n Block: > ('(' > block:Statement+ > ')') | block:Assignment\n Statement: (left:Block > connector:Connector > right:Statement) | (left:Block > !Connector)\n */\n}"; preg_match($re, $str, $matches); var_dump($matches);

preferences:
46.62 ms | 402 KiB | 5 Q