Use regular expressions to match an ? but not a \?

Posted by J.Milly on Stack Overflow See other posts from Stack Overflow or by J.Milly
Published on 2010-04-15T01:12:17Z Indexed on 2010/04/15 1:33 UTC
Read the original article Hit count: 409

I have a PHP regular expression that has been functioning fairly well to parse some odd legacy client templates until recently when we found an escaped question mark (\?) included in a template expression. I'm not strong enough with my regular expression-fu to wrap my feeble noodle around a negative look ahead or some techno-mumbo-jumbo so, tips or points in the right direction would be greatly appreciated.

My PHP:

preg_match_all("/\{\{IF (.*)\?(.*):(.*)\}\}/U", $template, $m, PREG_SET_ORDER);

© Stack Overflow or respective owner

Related posts about php

Related posts about regex