Re: How to match a token not be quoted?
- From: krahnj@xxxxxxxxx (John W. Krahn)
- Date: Mon, 28 Jan 2008 19:11:14 -0800
Zhao, Bingfeng wrote:
Hello,
Hello,
I want to a cure regex that match following requirements: given $line =
'abc abc "abc abcc" abcc', I want to replace all instances of "abc" that
not in quotation with, say 'd', so I expect I get 'd d "abc abcc" dc'.
What should I write my regex? I try some and referred cook book also, no
solution. Thanks in advance.
$ perl -le'
my $line = q[abc abc "abc abcc" abcc];
print $line;
$line =~ s/ ( " [^"]* " ) | abc / $1 || "d" /xeg;
print $line;
'
abc abc "abc abcc" abcc
d d "abc abcc" dc
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
.
- Follow-Ups:
- RE: How to match a token not be quoted?
- From: Bingfeng Zhao
- RE: How to match a token not be quoted?
- References:
- How to match a token not be quoted?
- From: Bingfeng Zhao
- How to match a token not be quoted?
- Prev by Date: Re: How to match a token not be quoted?
- Next by Date: How to avoid this greedy match?
- Previous by thread: Re: How to match a token not be quoted?
- Next by thread: RE: How to match a token not be quoted?
- Index(es):
Relevant Pages
|