Thread: PDF Input
View Single Post
Old 04-24-2010, 03:34 AM   #2
speakingtohe
Wizard
speakingtohe ought to be getting tired of karma fortunes by now.speakingtohe ought to be getting tired of karma fortunes by now.speakingtohe ought to be getting tired of karma fortunes by now.speakingtohe ought to be getting tired of karma fortunes by now.speakingtohe ought to be getting tired of karma fortunes by now.speakingtohe ought to be getting tired of karma fortunes by now.speakingtohe ought to be getting tired of karma fortunes by now.speakingtohe ought to be getting tired of karma fortunes by now.speakingtohe ought to be getting tired of karma fortunes by now.speakingtohe ought to be getting tired of karma fortunes by now.speakingtohe ought to be getting tired of karma fortunes by now.
 
Posts: 4,812
Karma: 26912940
Join Date: Apr 2010
Device: sony PRS-T1 and T3, Kobo Mini and Aura HD, Tablet
Hope This Helps
From Sams Book Teach Yourself Regular Expressions In 10 Minutes
Matching Digits (and Nondigits)
[0-9] is a shortcut for [0123456789] and is used to match any digit. To match anything other than a digit, the set can be negated as [^0-9]. Table 4.2 lists the class shortcuts for digits and nondigits.

Table 4.2. Digit Metacharacters Metacharacter
Description
\d
Any digit (same as [0-9])
\D
Any nondigit (same as [^0-9])
To demonstrate the use of these metacharacters, let's revisit a prior example:
var myArray = new Array();
...
if (myArray[0] == 0) {
...
}
myArray\[\d\]
var myArray = new Array();
...
if (myArray[0] == 0) {
...
}

\[ matches [, \d matches any single digit, and \] matches ], so that myArray\[\d\] matches myArray[0]. myArray\[\d\] is shorthand for myArray\[0-9\], which is shorthand for myArray\[0123456789\]. This regular expression would also have matched myArray[1], myArray[2], and so on (but not myArray[10]).

Last edited by speakingtohe; 04-24-2010 at 03:37 AM.
speakingtohe is offline   Reply With Quote