The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Worst Regexp I've Ever Written

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ryan Davis

Posts: 651
Nickname: zenspider
Registered: Oct, 2004

Ryan Davis is a ruby nerd.
Worst Regexp I've Ever Written Posted: Jan 14, 2008 2:29 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Ryan Davis.
Original Post: Worst Regexp I've Ever Written
Feed Title: Polishing Ruby
Feed URL: http://blog.zenspider.com/index.rdf
Feed Description: Musings on Ruby and the Ruby Community...
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Ryan Davis
Latest Posts From Polishing Ruby

Advertisement

This was part of a Parse::RecDescent grammar (or it might have been antlr by then) for a QA scripting tool that matched most perl 5 regexps. Note that nearly everything is double backslashed for the parser generator, not as part of the regexp.

  regex           : m/(
                       \\/(\\\\\\/|[^\\/])+?\\/
                  |   m\\((\\\\\\)|[^\\)])+?\\)
                  |   m\\[(\\\\\\]|[^\\]])+?\\]
                  | m\\\{(\\\\\\\}|[^\\\}])+?\\\}
                  |   m(.)(\\\\\\6|[^\\6])+?\\6)/x
                  | <error>

I'm mainly blogging this because I keep losing it. I think this is the correct unbackslashification:

m/  (\/(\\\/|[^\/])+?\/
 |  m\((\\\)|[^\)])+?\)
 |  m\[(\\\]|[^\]])+?\]
 |  m\{(\\\}|[^\}])+?\}
 | m(.)(\\\6|[^\6])+?\6)/x

Still gross as hell.

Read: Worst Regexp I've Ever Written

Topic: Command line clipboard access Previous Topic   Next Topic Topic: Vegas/SoCal road trip

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use