use strict;
my $str = '>nxp:NX_A0A0A6YYD4-1 \\PName=T cell receptor beta variable 13 isoform Iso 1 \\GName=TRBV13 \\NcbiTaxId=9606 \\TaxName=Homo Sapiens \\Length=124 \\SV=5 \\EV=31 \\PE=3 \\ModResPsi=(52|MOD:00798|half cystine)(120|MOD:00798|half cystine) \\ModRes=(106||N-linked (GlcNAc...) asparagine) \\VariantSimple=(18|H)(27|V) \\Processed=(1|31|PEFF:0001021|signal peptide)(32|124|PEFF:0001020|mature protein) MLSPDLPDSAWNTRLLCRVMLCLLGAGSVAAGVIQSPRHLIKEKRETATLKCYPIPRHDT VYWYQQGPGQDPQFLISFYEKMQSDKGSIPDRFSAQQFSDYHSELNMSSLELGDSALYFC ASSL
>nxp:NX_A0A1B0GV90-1 \\PName=Cortexin domain containing 2 isoform Iso 1 \\GName=CTXND2 \\NcbiTaxId=9606 \\TaxName=Homo Sapiens \\Length=55 \\SV=1 \\EV=11 \\PE=3 \\VariantSimple=(13|N)(22|F)(29|T)(34|Q)(45|T) \\Processed=(1|55|PEFF:0001020|mature protein) MEDSSLSSGVDVDKGFAIAFVVLLFLFLIVMIFRCAKLVKNPYKASSTTTEPSLS';
my $regex = qr/\\VariantSimple=((?:\([^\)]+\))*) \\Processed=((?:\([^\)]+\))*) ([\s\S]*?)(?:>|$)/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