Rexexp on part of a string
mike at altrion.org
Tue Feb 19 08:42:51 GMT 2008
On 19 Feb 2008, at 06:35, Andrew Black wrote:
> I would like to restrict the part of a string a regexp is allowed
> to operate on, For example I would like to ignore comments.
> I would like
> $x = " andrew andrew # andrew " ;
> $x =~ s/andrew/black/g ;
> to produce " black black # andrew "
you could simply split() on #, s/andrew/black/g and rejoin
or use a lookahead
Mike Whitaker - mike at altrion.org
More information about the london.pm