in reply to Using grep on windows

Your regexp "^CNR[0-9]" can never match as-is since you'll never have a beginning-of-line immediately following a ". You probably want to either drop the quotes (if the token always begins at the beginning of a line), or drop the caret (if the token always occurs in quotes). Not to mention \d is more concise than [0-9]

Update: Pedantry about [0-9] vice \d noted; suggestion withdrawn.

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: Using grep on windows
by JavaFan (Canon) on Oct 27, 2009 at 17:20 UTC
    Not to mention \d is more concise than [0-9]
    And . is even more concise.

    \d and [0-9] are not equivalent. The latter matches 10 characters, the former several hundreds.

      In general, yes, \d can match many more than 10 characters. In the above program, no. Even if it did, it wouldn't be a biggie.

      However, since it's being used for validation here, [0-9] is definitely way to go in my opinion.

      \d and 0-9 are not equivalent - you sure of that ?

      From Using character classes we see:

      \d is a digit and represents 1. 0-9

      A user level that continues to overstate my experience :-))

        \d matches a digit. There are more digits than 0,1,2,3,4,5,6,7,8,9.

        $ perl -Mcharnames=:full -le'print "\N{BENGALI DIGIT ZERO}" =~ /^\d\z/ + || 0' 1

        The same thing, written differently:

        $ perl -le'print chr(0x09E6) =~ /^\d\z/ || 0' 1