What tybalt89 said. This can be clearly seen by capturing and printing the matching substrings of the regex components:

c:\@Work\Perl\monks>perl -wMstrict -le "my $string = 'CME.b/ESM8'; print qq{'$1' '$2'} if $string =~ /^(CME\.b?)([^\/.])/; " 'CME.' 'b'

Update:

... please explain why ...
The regex engine tries its best to make an overall match any which way it can. The  b? match is specified as being optional. The  b? match assertion initially matches the  'b' character in the string, but the subsequent required  [^/.] match then fails for the reason noted in the OP. The regex engine then backtracks and eliminates the optional  b? match. It then has a  'b' character for  [^/.] to match, and the overall match succeeds.

Question: What would have happened if the  b match had not been optional (fairly obvious), or if it had been a  b?+ possessive (available in Perl versions 5.10+) optional match? (Update: Prior to version 5.10, the possessive quantifier modification effect can be achieved by wrapping the expression in a  (?>...) "atomic" grouping, so  (?>b?) would work exactly the same.)


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


In reply to Re: Strange negated character class behavior (updated) by AnomalousMonk
in thread Strange negated character class behavior by miguelnyc703

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.