in reply to Re: regex
in thread regex

No, perl seems to be able to parse the inner "[]" correctly even with the same characters as outer delimiters. The real problem with the original pattern is that "." is not a metacharacter inside character classes. The given class matched only real "."s and newlines. That's why I suggested the "s" option.

According to Mastering Regular Expressions, p. 10:

...to be clear, the only special characters within the class in [0-9A-Z_!.?] are the two dashes.

Replies are listed 'Best First'.
Re: Re: Re: regex
by Nkuvu (Priest) on Jun 19, 2003 at 15:36 UTC

    Wow, learn something new every day. I looked it up in perldoc perlop and found this relevant bit:

    Non-bracketing delimiters use the same character fore and aft, but the four sorts of brackets (round, angle, square, curly) will all nest, which means that q{foo{bar}baz} is the same as 'foo{bar}baz'

    And if I'd taken more than a second to glance at it, I would have noticed the non-metacharacter '.' inside the square brackets. I'm familiar with that particular pitfall, having done it in my own code many times. But thanks for pointing it out.