regular expressions

Regex for Quoted String with escapable quotes

This post is a long-format reply to Jonathan Jordan's recent post. Jonathan's post was about the non-capturing backreference in Regular Expressions. He and I are both working a lot in Behat, which relies heavily on regular expressions to map human-like sentences to PHP code. One of the common patterns in that space is the quoted-string, which is a fantastic context in which to discuss the backreference (and also introduce lookarounds).

What I Learned Today: Regular Expression Backreferences

This is another post in my challenge to learn something new every day and then share that in a blog post.

This is fairly simple, but even though I'm comfortable with regular expressions, I was not familiar with the "?:" syntax (aka: question mark colon). I was working on some Behat tests using the MinkExtension, and this is used fairly often in the code (?P<option>(?:[^"]|\\")*).

Ready for transformation?