use strict;
my $str = 'ch.iqos.com
discoveriqos.com
faramentol.ro
foodhouse.md
futurosinhumo.com
ganaconpmi.com
getinfo.kr
heatnotburn.se
iqommunity.ro
iqosclub.cz
iqosclub.sk
iqosclubcanarias.com
iqosempfehlen.at
iqositalia.it
iqosphere.jp
iqossvc.kr
iqosveda.cz
iqosveda.sk
newcreations.kr
prohibicionmentolado2020.es
proibicao-mentol2020.pt
qreator.ro
referiqosmy.com
shareiqos.ch
timeforchanges.ch
tryiqos.kr
unsmoke.de
iqostravel.com
iqostage.jp
iqos-register.jp
mystartapp.org
iqosclub.ch
dimensions.kz
www.tryiqos.ru
www.timeforchanges.ch
www.testiqos.ch
readmodel.m.sogou.com
www.shareiqos.ch';
my $regex = qr/(?i)^.*\.(.*\.[a-z]{0,3})|(?i)([a-z]{0,3}\..*\.[a-z]{0,3}|.*\.[a-z]{0,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