in reply to working with \Q and \E

Probably it's the \b that's screwing you up. Read perldoc perlre for the full explanation, but basically it means a point in the string where there's a transition from a \w character to a \W character (or vice versa). This condition doesn't exist for ":)" so the regex doesn't match and your substitution won't be done.

DB<4> $_ = ":) cat :)" DB<5> s/\b/^/g DB<6> x $_ 0 ':) ^cat^ :)'

Replies are listed 'Best First'.
Re^2: working with \Q and \E
by Roy Johnson (Monsignor) on Feb 24, 2005 at 20:37 UTC
    The solution is to roll your own lookahead and lookbehind. Since the apparent intent is to avoid substituting in the middle of words,
    $message =~ s|(?<!\w)\Q$face\E(?!\w)| <img src="$location" alt="$name" +> |gi
    should work.

    Caution: Contents may have been coded under pressure.