TIMTOWTDI (unnecessarily verbose, but perhaps easy to follow and illustrating some possibilities with lookaheads):
#! /usr/bin/perl use strict; use warnings; my $text = 'From: aaa@bb.netxxxMessage-Id: xxx<200902131530.n1DFUZ5l00 +1303@aaa.bb.net>xxxTo: xxx@yyy.netxxxSubject: Size atanan xxx numaral +i ticket hakkindaxxxContent-Type: text/plain; charset=ISO-8859-9xxxCo +ntent-Transfer-Encoding: 7bit'; if ( $text =~ /(?=To:\s)(.+)(?=[^x]{3})/ ) { $text =~ /.+To:\s(.*?)(?=xxxSubject)/; my $to_email = $1; print $to_email . "\n"; } else { print "no match\n"; }
Output:
xxx@yyy.netas specified.
Your OP would have been easier to parse had you included data and code inside <c>...</c> tags as done above.
In reply to Re: Regex substitution problem
by ww
in thread Regex substitution problem
by mahira
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |