Category Archives: regular expressions

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 […]

Updates to Chapter 9, “Processing Text with Regular Expressions”

[This post notes differences between the fifth and sixth editions.] I didn’t have to make many changes to this chapter. I wanted to put in at least one Perl 5.14 feature, but the only new thing that the substitution operator gets is the /r modifier. While working through this chapter though, I started to wonder […]