use strict;
my $str = '성 벼 | 5 번YAO LIAO거 CHINA P R체류자격 결혼이민F-1)말급일자\', # \'YAO LIAO\'
성 별 F 등록번호명 JAO HALJUNGCHINA P R격 결혼이민(F-6)밥급인자\', # \'JAO HALJUNG\'
성 별 F명 CHENG HAIJING국 가 CHINA P R 역체 가차격 결혼이민(C-4) 박급인자\', # \'CHENG HAIJING\'
KOa MDOVUD TAREEQ SAID HAFIZULLAH TURKIYE움첫;자격 거주(F-2)발급일자\', # \'DOVUD TAREEQ SAID HAFIZULLAH\'
KOn 별 MDOVUD TAREEQ SAID- IIAFIZULLAH 감 TURKIYE동체나자격 거주F-2) 발급일자\', # \'DOVUD TAREEQ SAID- IIAFIZULLAH\'
등록번호IN" 성 별 M명 TAREEQ SAD IIAFIZULLAH 값 TURKIYE8체주자격 거주-2)발급일자\' # \'TAREEQ SAD IIAFIZULLAH\'
]';
my $regex = qr/^.*?((?!MDOV)[A-Z]{2,}(?: (?:(?!CHIN|TURK)[A-Z]){2,}){1,2})/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