in reply to case preservation in regexp

Or print "<span class='topic'>$1</span>" if /\b(cat)\b/i;

Update: Added the missing parentheses (thanks halley)

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Replies are listed 'Best First'.
Re^2: case preservation in regexp
by halley (Prior) on Feb 10, 2005 at 18:04 UTC
    Parentheses matter. You didn't capture a $1.
    print "<span class='topic'>$1</span>" if /\b(cat)\b/i;
    If only the first letter should be flexible,
    print "<span class='topic'>$1</span>" if /\b([Cc]at)\b/;

    --
    [ e d @ h a l l e y . c c ]