trying to build a regular expression to match bus names in a design.

so if the bus is pce_rx_n[15:0], I want to be able to match pce_rx_n1 but not pce_rx_n10...pce_rx_n15

I can't figure out what to put at the end of the regex..

I can't use a dollar at the end of the regex because i also want to match pce_rx_n1_blah

I've tried /pce_rx_n1\D/ but that only works for the pce_rx_n1_blah case

/pce_rx_n1\D?/ doesn't work because no \D will match

I thought this might be the answer... but no dice /pce_rx_n1[\D$]?/

#!/usr/bin/perl -w use strict; #setup bus pins my @pinList=(); for my $i (0..15) { push @pinList,"pce_rx_n$i"; push @pinList,"pce_rx_p$i"; push @pinList,"pce_tx_n$i"; push @pinList,"pce_tx_p$i"; push @pinList,"cwx_tx_n${i}_blah"; push @pinList,"cwx_rx_p${i}bleh"; } # #Here lies the match string I am trying to build #I loosened it up more to match the tx or rx pins with any # pce or cwx prefix #my $match_str="[tr]x_n1[\\D\$]"; # #here is the Fix from Anaomalous Monk using the zero width #negative look-ahead assertion # my $match_str="[tr]x_n1(?!\\d)"; print "match_str=$match_str\n"; #now highlight any matches foreach my $pn (@pinList){ print "$pn"; if ($pn=~/$match_str/i) { print "***"; } print"\n"; }

In reply to regular expression to match specific members of a bus_name by boleary

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.