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.orgThread Previous | Thread Next