Category Archives: regular expressions

Debuggex visualizes regular expressions

Debuggex can turn PCRE regular expressions into railroad diagrams. It’s missing several advanced Perl features, but it’s good for the basic patterns you’ll create in Learning Perl:

Watch regexes with Regexp::Debugger

Wouldn’t it be great if books had embedded videos? That would make programming textbooks so much easier. We have to give some hints about how regexes work in the first regex chapter in Learning Perl. It’s hard to describe something like greedy matching and backtracking with only words. It seems like it should be simple […]

The evolution of character class shortcuts

Character class shortcuts used to be easy because ASCII was easy. Either of those were easy if ASCII was what you wanted, but quite limiting otherwise. Perl v5.6 introduced Unicode support and the world started to change. A good programmer is always trying to eliminate ambiguity. Their code should work the same way everywhere, but […]

Captures with quantifiers match the last captured substring

A student in my Learning Perl class asked about what shows up in a capture when you apply a quantifier to that group. The great thing about computer programming is that you can just try it to find out:

The vertical tab now matches \s

Perl 5.18 added vertical tab (or LINE TABULATION in the UCS) to the characters that match the \s character class shortcut. It’s the one exception that made that shortcut different from the POSIX definition of whitespace. For the details, see my posts in The Effective Perler: The vertical tab is part of \s in Perl […]