Thursday, February 25, 2010

Start/End of String/Line regular expression in Ruby

Regular expressions about "Start of string", "Start of line", "End of line" and "End of String" are difficult and complex because of differences in each programming languages. So I try to explain Ruby's case visually.

There is a multi-line string like below:
Title

one
two, three, four


five, six, seven
eight, nine, ten



And each regular expressions (\A, ^, $, \Z, \z) match like below:


Title

one
two, three, four


five, six, seven
eight, nine, ten

No comments:

Post a Comment