use strict;
my $str = '1([A-Z]|[a-z])+
Scroll of Renaming (1)
Seller: Rogrinus
Expires in: 07 hr, 09 min, 46 sec
Selling price:
200000
1
Secondary Gene: Loop (Veilspun) (1)
Seller: Natta
Expires in: 09 hr, 21 min, 47 sec
Selling price:
200000
1
Primary Gene: Python (1)
Seller: PlatinumStardust
Expires in: 1 days, 07 hr, 37 min, 50 sec
Selling price:
200000
1
Primary Gene: Stitched (Veilspun) (1)
Seller: lizagem
Expires in: 2 days, 11 hr, 07 min, 56 sec
Selling price:
200000
1
Primary Gene: Stitched (Veilspun) (1)
Seller: ScarletCyanide
Expires in: 3 days, 06 hr, 31 min, 26 sec
Selling price:
200000
1
Tertiary Gene: Capsule (Veilspun) (1)
Seller: forcipiger
Expires in: 4 days, 04 hr, 15 min, 26 sec
Selling price:
200000
1
Tertiary Gene: Firefly (Veilspun) (1)
Seller: Pyracantha
Expires in: 4 days, 23 hr, 35 min, 53 sec
Selling price:
200000
1
Primary Gene: Python (1)
Seller: sisyo
Expires in: 5 days, 13 hr, 59 min, 20 sec
Selling price:
200000
1
Tertiary Gene: Squiggle (Banescale) (1)
Seller: BananaMeteor
Expires in: 5 days, 18 hr, 32 min, 31 sec
Selling price:
200000
1
Primary Gene: Skink (1)
Seller: H0ur
Expires in: 6 days, 13 hr, 07 min, 31 sec
Selling price:
200000
';
my $regex = qr/^(Primary|Secondary|Tertiary).Gene:.([A-Z]|[a-z])+ \(1\)/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