in reply to Regex substitution problem

$to_email =~ s/.+To:\s(.*?)xxx/\1/;

will do what you want. The * is greedy which means it will take as much as it can. The '?' changes the * to a non-greedy version

Replies are listed 'Best First'.
Re^2: Regex substitution problem
by mahira (Acolyte) on Feb 14, 2009 at 13:07 UTC

    Thanks. But the result changes slightly

    xxx@yyy.netSubject: Size atanan xxx numarali ticket hakkindaxxxContent-Type: text/plain; charset=ISO-8859-9xxxContent-Transfer-Encoding: 7bit

    (the xxx near the e-mail address disappeared)