in reply to regex question: $1 vs. \1

Yes. the regex centered ops s/// and m// take \1 in the regex itself for the first fully matched pattern in parentheses. $1 means the same in the second argument or until the next regex.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: regex question...
by count0 (Friar) on Dec 23, 2001 at 12:43 UTC
    Additionally:
    Although you can use \(digit) in the right side of a s/// operation, you shouldn't. This was included (i would guess) just to appease the sed junkies out there ;)

    Generally the only time \(digit) should be used is on the LHS of a s///, or within a m//.
    Example:
    /(foo)\1/; # is effectively the same as /(foo){2}/;