in reply to Re: Using grep on windows
in thread Using grep on windows

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.

Replies are listed 'Best First'.
Re^3: Using grep on windows
by ikegami (Patriarch) on Oct 27, 2009 at 17:42 UTC

    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.

Re^3: Using grep on windows
by Bloodnok (Vicar) on Oct 27, 2009 at 17:40 UTC
    \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