Delimiter woes
Posted: Fri Mar 30, 2007 5:57 am
I'm currently working on a parser for the YAML format. Since the lexer needs to scan for tokens, it uses quite a bit of regex and this one has me stumped. Maybe after another few cups of coffee I'll break it
.
The regex itself looks fine, it matches checks there are no "special" characters at the start of a new line, and for a subset of those (which are allowed) that they are not followed by any tabs, spaces, null bytes or other wonky things. So far so good. When using it the lexer coughs up an Exception and PHP sends out a Warning:
Anyone have a clue where it's gone wrong?
The regex itself looks fine, it matches checks there are no "special" characters at the start of a new line, and for a subset of those (which are allowed) that they are not followed by any tabs, spaces, null bytes or other wonky things. So far so good. When using it the lexer coughs up an Exception and PHP sends out a Warning:
I used a unique delimiter in case it was a loose non-escaped forward slash or something obvious I missed. Left the double quotes in place around the regex string...Warning: preg_match() [function.preg-match]: No ending delimiter '£' found in Yaml\Lexer.php on line 222
Code: Select all
"£^([^\0 \t\r\n\x85\-?:,\[\]{}#&*!|>'\"%@]|([\-?:][^\0 \t\r\n\x85]))£"