Apr 28, 2003 at 10:29am from Ravi Malghan: RM> $_ = "attr1 val1\nattr2 val2\nattr3 val3"; RM> RM> I want to substitute "attr2 val2" with "attr2 val4" RM> s/.*(attr2 .*)\nattr3.*/"attr2 val4"/; s/attr2 val2/attr2 val4/; If you want to capture the "attr2 val4", or if you don't know what val2 is going to be, that's okay too: s/attr2 (\S+)/attr2 val4/; and now val2 is stored in $1. Note that if you want to match your regex across the \n, treat the string as a single string by adding an 's' flag to the end of the regex. That doesn't apply in this case, since what you're relacing is all on one line. Pete -- http://emerson.wss.yale.edu/perl Pete Emerson WSS AM&T Yale UniversityThread Previous | Thread Next