21 Aug 2008 fxn   » (Master)

Gotcha: Ruby and Perl conflicting regexp flags

Both Ruby and Perl have /m and /s regexp flags, but they are different in each language.

  • To have the dot match newlines you use /s in Perl, but /m in Ruby.
  • To enable multiline mode, that is ^ matches beginning of line, you use /m in Perl and nothing in Ruby. In Ruby that's the only existing mode, you can't switch it off, ^ asserts beginning of line always. Beginning of string is \A and end of string \z or \Z as in Perl.
  • If that was not confusing enough, Ruby has a /s flag which means the regexp is in SJIS encoding.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!