use strict;
my $str = '10001|W20101|W20101|G00001||||學徒劍盾|8|9|768||-1|1||||||||40002||||||1|14||2||40027|40028|40029|40030||2|22|113|||||||||||2|50|100|7|||||
10002|W30101|W30101|G00001||||學徒大斧|9|9|768||-1|1||||||||40003||||||1|17||3||40031|40032|40033|40034||2|26|142|||||||||||2|50|100|9|||||
10479|I00208||G00005||||青鐵礦|29||0||-1|30||||3|||||||||100|5|1||54|$53$原始的礦石,整體泛著鐵青的色澤。
#IMG$NoticeIcon#30~45級的副本掉落或跟公會商人購買。
$7$能與其他材料結合,製作40級的合金材料。
|||||||||||||||||||||||||||';
my $regex = qr/^[^|]*(?:\|[^|]*){58}$/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