in reply to Pattern Matching Question

The regex expression [^"] is a character class, the caret meaning, as you say, negation - 'anything but what follows'. The * after that means matc zero or more of them, greedily. The parentheses capture what's matched in $1. The enclosing quotes are matched literally. The result is that everything between the first and second quote is captured.

Another way would be to use a non-greedy expression in the capture, /"(.*?)"/

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Pattern Matching Question
by Abigail-II (Bishop) on Sep 10, 2003 at 15:22 UTC
    Another way would be to use a non-greedy expression in the capture, /"(.*?)"/

    Uhm, not quite. You'd have to use /"(.*?)"/s. Furthermore, if you would embed the regex in a larger one, "[^"*]" would never match a double quote inside the other ones, while ".*?" may.

    Abigail