On 13 July 2010 13:00, Bryan R Harris <bryan_r_har...@raytheon.com> wrote:
>
> I thought this would work:
>
>  s/(['"])([^\1]*)\1/${1}.despace($2).$1/gse;
>

> ... but it doesn't.  It looks like the [^\1]* in the regexp isn't working
> right.

Character classes (characters inside square brackets - []) in regexp
notation, interpret whatever is inside sometimes differently than it
would be interpreted otherwise, with backslash taking a different
meaning so \1,\2 back-references doesn't have the special meaning it
has outside of the square brackets. There are other hijinks regarding
backspace functionality inside character classes, which are
sporadically documented in the different regexp descriptions and
manuals.

For what you need, I suggest a negative lookahead, i.e. (?!\1) for
zero-length lookahead.

-- 
Erez

Observations, not opinions

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to