System Status

13 Responses

  1. Markus

    Nell,
    great stuff and explained the way it should be. This post will be found in my “recommend for our developers” folder.

    -MK

    1. Nell Shamrell

      Thanks! I’m so glad it was helpful!

  2. Using Regular Expressions in Ruby (Part 1 of 3) | Ivan Enviroman

    [...] Nell Shamrell from BlueBox.net provides an excellent tutorial on Regular Expressions in Ruby: http://www.bluebox.net/about/blog/2013/02/using-regular-expressions-in-ruby-part-1-of-3/ This entry was posted in Bookmarks and tagged regex, rubyonrails by ivanoats. Bookmark the [...]

  3. Art

    The unicode quotations marks in the code samples throw errors when pasted into irb.

  4. Eli

    If you’re just doing basic matching without patterns and other advanced features, may I suggest checking out my MUCH faster regular expressions library for Ruby? http://github.com/elitheeli/regu — it doesn’t have all the features yet that it could have but works perfectly fine if a big, real regular expression is a bottleneck in your code.

  5. Brian Kung

    Nell, this is an incredible guide. Just finding out about !~ is worth reading all three posts, in and of itself. One small request – can you put the links to parts 2 and 3 in the body of the article so I don’t have to bookmark all of them? And believe me, I have to bookmark this :)

    Thanks for writing!

    1. Nell Shamrell

      Done. And you are quite welcome!

  6. john

    I’m fond of the convenience method on String to get a capture group.

    In irb:

    “451-3168″[/(\d{3})-(\d{4})/, 2]

    To get the 2nd sequence of digits, when the String matches ###-####

  7. Jabari

    Your last example didn’t show the full output. I get this.

    2.0.0p0 :061 > my_match.to_a.each do |m| puts m.upcase end
    THE FORCE WILL BE WITH YOU ALWAYS
    THE
    WILL BE WITH YOU ALWAYS
    => ["The force will be with you always", "The ", " will be with you always"]

    1. Nell Shamrell

      You are quite right. Fixed!

  8. Zaid Akram

    Im already waiting for 2nd and 3rd part. Great stuff. Keep it up!

  9. Eric Hutzelman

    Quick fix to the pre_match example:

    my_match.pre_match
    => “The”

    should have a space included at the end:

    my_match.pre_match
    => “The ”

    1. Nell Shamrell

      Good catch. Fixed!

Leave a Reply