How about:
my $strA = q~<IMG SRC="/include/images/moredetails.png" WIDTH="8" HEIGHT="7" ONMOUSEOVER="return createPopup('<b>[scan_name@user:home]:</b> <!-- #EscapedName# --><br><b>[organization@user:home]:</b><br><!-- #EscapedOrganizationPath# --><br><b>[total@user:home]:</b> <!-- #EscapedTotal# --><br><b>[high@user:home]:</b> <!-- #EscapedHigh# --><br><b>[medium@user:home]:</b> <!-- #EscapedMedium# --><br><b>[low@user:home]:</b> <!-- #EscapedLow# --><br><b>[date_last_scanned@user:home]:</b> <!-- #EscapedDate# -->');" ONMOUSEOUT="return nd(1000);"><!-- #Name# --></TD>~;
my $strB = q~<IMG SRC="/include/images/moredetails.png" WIDTH="8" HEIGHT="7" ONMOUSEOVER="return createPopup('<b>[scan_name@user:home]:</b> <!-- #EscapedName# --><br><b>조직/부서 경로:</b><br><!-- #EscapedOrganizationPath# --><br><b>[total@user:home]:</b> <!-- #EscapedTotal# --><br><b>[high@user:home]:</b> <!-- #EscapedHigh# --><br><b>[medium@user:home]:</b> <!-- #EscapedMedium# --><br><b>[low@user:home]:</b> <!-- #EscapedLow# --><br><b>[date_last_scanned@user:home]:</b> <!-- #EscapedDate# -->');" ONMOUSEOUT="return nd(1000);"><!-- #Name# --></TD>~;
while($strA =~ /(.*?)\[([^\]]+?)\](.)/g) {
my $prefix = $1;
my $tag = $2;
my $suffix = $3;
print "prefix=$prefix\ntag=$tag\nsuffix=$suffix\n";
print "found it $1\n\n" if ($strB =~ /\Q$prefix\E\[?([^\[\]]+)\]?\Q$suffix\E/g);
}
If you want a longer suffix to avoid overlap, you can use this:
while($strA =~ /(.*?)\[([^\]]+?)\]([^[]*))/g) {
Output:
prefix=<IMG SRC="/include/images/moredetails.png" WIDTH="8" HEIGHT="7" ONMOUSEOVER="return createPopup('<b>
tag=scan_name@user:home
suffix=:
found it scan_name@user:home
prefix=</b> <!-- #EscapedName# --><br><b>
tag=organization@user:home
suffix=:
found it 조직/부서 경로
prefix=</b><br><!-- #EscapedOrganizationPath# --><br><b>
tag=total@user:home
suffix=:
found it total@user:home
prefix=</b> <!-- #EscapedTotal# --><br><b>
tag=high@user:home
suffix=:
found it high@user:home
prefix=</b> <!-- #EscapedHigh# --><br><b>
tag=medium@user:home
suffix=:
found it medium@user:home
prefix=</b> <!-- #EscapedMedium# --><br><b>
tag=low@user:home
suffix=:
found it low@user:home
prefix=</b> <!-- #EscapedLow# --><br><b>
tag=date_last_scanned@user:home
suffix=:
found it date_last_scanned@user:home