in reply to Extracting data after a match

I don't know whether you want to catch the string before zyx, using the /g and \G may not be necessary if you don't care about it, although it would ensure that you get the right zyx. How about something like:

$line[0]="12/123 11-abc 456 a 1/2 zyx this is the last"; $line[1]="14/456 11-abc 456 a 1/2 zyx this is it"; for (@line) { if(m|(\d+/123 11-[a-z]+ \d+)|g) { $start=$1; /\G(.*?) zyx (.*)$/; print "Start of record:$start\nBefore zyx:$1\nand Afte +r zyx:$2\n"; } } __OUTPUT__ Start of record:12/123 11-abc 456 Before zyx: a 1/2 and After zyx:this is the last