Another variation:

c:\@Work\Perl\monks>perl -wMstrict -le "my $path = 'XX.YY.ZZ'; my ($ignore) = map qr{ (?: $_) (?! [[:alpha:]]) }xms, join q{ | }, qw(if while for) ; ;; my $s = '(ABC | (~dEf & hIJ)) & ~LMn if form while i'; ;; my $expected = '(XX.YY.ZZ.ABC | (~XX.YY.ZZ.dEf & XX.YY.ZZ.hIJ)) & ~XX +.YY.ZZ.LMn if XX.YY.ZZ.form while XX.YY.ZZ.i'; print qq{expected: '$expected'}; ;; $s =~ s{ (?<! [[:alpha:]]) (?= [[:alpha:]]) (?! $ignore) } {$path.}xmsg; print qq{ got: '$s'}; $s eq $expected or die 'FAILED'; print 'a-ok'; " expected: '(XX.YY.ZZ.ABC | (~XX.YY.ZZ.dEf & XX.YY.ZZ.hIJ)) & ~XX.YY.ZZ +.LMn if XX.YY.ZZ.form while XX.YY.ZZ.i' got: '(XX.YY.ZZ.ABC | (~XX.YY.ZZ.dEf & XX.YY.ZZ.hIJ)) & ~XX.YY.ZZ +.LMn if XX.YY.ZZ.form while XX.YY.ZZ.i' a-ok
(Long lines: Beware linewrap.)

Update: Just took another look at Re^2: Appending strings and realized solution above doesn't cover "1'b0" or "ABC_DEF". These could be included, but I'm sure that wouldn't be the end of it. Yeah, a real Verilog parser looks like the best bet.


Give a man a fish:  <%-{-{-{-<


In reply to Re: Appending strings by AnomalousMonk
in thread Appending strings by doofus

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.