Re: How to match a token not be quoted?



Zhao, Bingfeng wrote:
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'.

$line =~ s/("[^"]*")|abc/$1 ? $1 : 'd'/eg;

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.



Relevant Pages

  • Re: How to match a token not be quoted?
    ... Rob Dixon wrote: ... not in quotation with, say 'd', so I expect I get 'd d "abc abcc" dc'. ... Gunnar Hjalmarsson ...
    (perl.beginners)
  • Re: How to match a token not be quoted?
    ... Zhao, Bingfeng wrote: ... I want to a cure regex that match following requirements: ... not in quotation with, say 'd', so I expect I get 'd d "abc abcc" dc'. ...
    (perl.beginners)
  • Re: How to match a token not be quoted?
    ... Zhao, Bingfeng wrote: ... not in quotation with, say 'd', so I expect I get 'd d "abc abcc" dc'. ... What should I write my regex? ...
    (perl.beginners)
  • How to match a token not be quoted?
    ... I want to a cure regex that match following requirements: ... not in quotation with, say 'd', so I expect I get 'd d "abc abcc" dc'. ... Bingfeng ...
    (perl.beginners)
  • Re: How to match a token not be quoted?
    ... Gunnar Hjalmarsson wrote: ... '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'. ...
    (perl.beginners)