in reply to Re^3: Regex Tool
in thread Regex Tool
/s changes the dot's normal definition - match any char except a new line (\n).
In single mode the dot can match \n too which allows regex phrases like:
.*
to match across the end of line. That all it does and so its why the "item.*" in your example matches the end of line.
/m changes the ^ and $ anchors from absolute beginning and end of string to match beginning and end of a line, as marked by new line chars. Which is useful w/ the '/g' option, for example:
Not a useful snippet but ... two notes - the '\n' on the print stmt and notice the diff if you put an 's' in the match optionslocal $/ = undef; my $whole_file = <>; # slurp while ( $whole_file =~ /^(.*)$/mg ) { # process line by line print "Got: $1\n"; }
a
|
---|