develooper Front page | perl.beginners | Postings from April 2003

RE: help with substiution

Thread Previous | Thread Next
From:
Sulabh Agarwal
Date:
April 28, 2003 10:40
Subject:
RE: help with substiution
Message ID:
0252DA9D658BBD46880B050E509B3CC51188A8A3@mercury-nbu.epicsys.com
Maybe I am understanding this incorrectly, but it seems like in order to
replace attr2 val2 with attr2 val4 all you need to do is
s/attr2 val2/attr2 val4/;

In case for some specific reason you need to get the data before and
after attr2 val2 then you should use .*? . This will ensure minimal
matching. Read up on minimal matching for more info.

HTH.

Sulabh Agarwal

-----Original Message-----
From: Ravi Malghan [mailto:rmalghan@yahoo.com] 
Sent: Monday, April 28, 2003 12:30 PM
To: beginners@perl.org
Subject: help with substiution


Hi: I am not able to perform a substition in the
following string

$_ = "attr1 val1\nattr2 val2\nattr3 val3";

I want to substitute "attr2 val2" with "attr2 val4"
s/.*(attr2 .*)\nattr3.*/"attr2 val4"/;

The above substitution does not seem to be working.
Could somebody help?

Thanks
Ravi


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com

-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About