in reply to regex

Huh. My first thought is that your qr operator is using [ and ] as delimiters. And you have [.\n] in your regex. Seem like a problem?

I only briefly read the other replies, to see if someone else pointed this out. So this might not be the problem at all -- or the only problem. But...

Replies are listed 'Best First'.
Re: Re: regex
by tall_man (Parson) on Jun 19, 2003 at 14:38 UTC
    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.

      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.