in reply to regular expression to match specific members of a bus_name

Are you sure about what \D means?
  • Comment on Re: regular expression to match specific members of a bus_name

Replies are listed 'Best First'.
Re^2: regular expression to match specific members of a bus_name
by boleary (Scribe) on Feb 12, 2016 at 12:17 UTC

    I thought it meant not a digit?

      What AnonyMonk may be getting at is the sometimes tricky difference between \D and (?! \d):

      • \D requires the presence of a non-digit character, so 'xyz1' will not match against /\d\D/;
      • (?! \d) only requires the absence of a digit character, and the end of the string qualifies as this absence so 'xyz1' will match against /\d(?!\d)/ — as you have discovered!
      c:\@Work\Perl\monks>perl -wMstrict -le "my $s = 'xyz1'; ;; print '/\d \D/ matches' if $s =~ m{ \d \D }xms; print '/\d (?! \d)/ matches' if $s =~ m{ \d (?! \d) }xms; " /\d (?! \d)/ matches


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