I <3 Regexs

I was toying around with regexs this morning and learned a few things I had just never taken the time to learn before. In any case, I came up with this:

#((?:(?<!\\)\"(?:(?:(?:[\x20\x09]*[\r\n])?[\x20\x09]+)?(?:[\x01-\x08\x0b-\x0c\x0
e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|\\[\x01-\x09\x0b-\x0c\x0e-\x7f]))*(?:(?:[\x20\
x09]*[\r\n])?[\x20\x09]+)?\"|[^"(]+|\\["(]|^)+)(?:(?:(?:(?:(?:[\x20\x09]*[\r\n])
?[\x20\x09]+)?(?P<comment>\((?:(?:(?:[\x20\x09]*[\r\n])?[\x20\x09]+)?(?:[\x01-\x
08\x0b-\x0c\x0e-\x1f\x7f\x21-\x27\x2a-\x5b\x5d-\x7e]|\\[\x01-\x09\x0b-\x0c\x0e-\
x7f]|(?P>comment)))*(?:(?:[\x20\x09]*[\r\n])?[\x20\x09]+)?\)))+(?:(?:[\x20\x09]*
[\r\n])?[\x20\x09]+)?|(?:[\x20\x09]*[\r\n])?[\x20\x09]+))#

(of course ignoring line breaks.) An ‘atta boy’ (or girl as the case may be) to anybody that can tell me what this would be used for :P .

This entry was posted in PHP. Bookmark the permalink.

7 Responses to I <3 Regexs

  1. Ben says:

    Destroying alien invaders by confusing their computer systems?

  2. *blink* *blink* *blinkity blink*

  3. That would defenatly be used to get people to waste their time trying to figure it out :P PP or get a raise by showing l33t sk1llz :)

  4. Anonymous says:

    Mmm, it’s so strange, does it have a meaning?

  5. I’ll tell you what it isn’t used for – doing anything at all with EBCDIC!

  6. glen says:

    Any reason you went for the difficult to read, difficult to remember \x20\x09 instead of just \s?

  7. Mike Lively says:

    Yah, the \s character is more encompassing than just space and tab. It includes line feeds and carriage returns as well as the form feed character (\f) which the RFC doesn’t allow.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>