use strict;
my $str = '.abc@ornekeposta.com
_abc@ornekeposta.com
9abc.@ornekeposta.com
!@ornekeposta.com
a!@ornekeposta.com
ö@ö@.ö
#4+^%+@göl.çöz
!\'^+%&&/)=?:_@^+%+^&%(.+%^+%%+/&%&.com
a_@a.aa
21322534@435345345.4353.4543
a@aa.aa
1@12.co
a.1@555555.com
a@ornekeposta.com
9abc@ornekeposta.com
abc@ornekeposta.org.tr
m@it.ai.tr.cz.ru.dart
name@surname.aero
AAAA@AAA.AA
deneme+tag@deneme.com
very-important@person.international
istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul-istanbul.istanbul.istanbul.istanbul+istanbul@4istanbul.istanbul-istanbul-istanbul-istanbul-istanbul.istanbul.ista.istanbul
';
my $regex = qr/^(?=.{6,284}$)[^\W_](?:[+\w.-]*[^\W_])?@[^\W_](?:\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.|(?:[\w-]+\.)+)(?:[a-zA-Z]{2,13}|[0-9]{1,3})\]?$/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html