I used your suggestions as the base for my change. The occasional H was missing, and I added some /i flags to the numeric patterns. And renamed to keep things closer to what I had/want.

I was surprised that I had to escape the slashes in a comment of the big regexp, else they were misdetected as ending the regexp.

my $pathex2 = qr/[0-9A-F]{2}/i; # exactly 2 hex digits my $pathex2p = qr/[0-9A-F]{2,}/i; # 2 or more hex digits my $pathexX1t4= qr/[0-9A-FX]{1,4}/i; # 1-4 hex/X digits my $pathexX1t8= qr/[0-9A-FX]{1,8}/i; # 1-8 hex/X digits my $patopt_h = qr/h?/i; # optional trailing H/h my $patoptname= qr/(?:\"[^\"]+\")?/; # optional quoted literal (nam +e) my $patint = qr/\bINT\s?$pathex2$patopt_h/; # INT <byte> my $patmem_16_16 = qr/\bMEM\s?$pathexX1t4$patopt_h:$pathexX1t4$patopt_h/; # MEM <a +ddr>:<addr> my $patmem_32 = qr/\bMEM\s?$pathexX1t8$patopt_h/; # MEM <add +r> my $patportrange = qr/ \bPORT\s?$pathexX1t4$patopt_h\-$pathexX1t4$patopt_h/x; # PORT < +range> my $patportsingle= qr/\bPORT\s?$pathexX1t4$patopt_h/; # PORT <s +ingle> my $pattable = qr/\#[0-9A-Z][0-9]{4}\b/; # #<letter><4 +digits> my $pataccureg = qr/\bE?A[XHL]=$pathex2p$patopt_h/; # EAX/AH/ +AL assignment my $patregequ = qr/ (?:E?[ABCD][XHL]|E?[SD]I|E?[SB]P|[DESC]S)=$pathex2p$patopt_h /x; # a single register entry my $patreglists = qr/ (?:\/$patregequ)+ /x; # one or more "/<reg>" entries our $hyperlinkpattern = qr/ # 1. INT with register list and optional name (?<intplus> $patint $patreglists $patoptname ) | # 2. INT with only optional name (?<intonly> $patint $patoptname ) | # 3. EAX\/AH\/AL equation with optional register list and optional + name (?<regonly> $pataccureg (?:\/$patregequ)* $patoptname ) | # 4. Table reference (?<table> $pattable ) | # 5. MEM far address (addr:addr) with optional name (?<mem_16_16> $patmem_16_16 $patoptname ) | # 6. MEM single address with optional name (?<mem_32> $patmem_32 $patoptname ) | # 7. @ reference (addr:addr) with optional name (?<call> \@$pathexX1t4$patopt_h:$pathexX1t4$patopt_h $patoptname ) | # 8. PORT range with optional name (?<portrange> $patportrange $patoptname ) | # 9. PORT single value with optional name (?<portsingle> $patportsingle $patoptname ) /x;

In reply to Re^3: Reusing a complex regexp in multiple spots, escaping the regexp by ecm
in thread Reusing a complex regexp in multiple spots, escaping the regexp by ecm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.