Digit and Word Character Classes
Regular expressions provide shorthand codes (often called metacharacters) to represent common sets of characters. Instead of writing verbose ranges like [0-9] or [a-zA-Z0-9_], you can use these predefined character classes to make your patterns more readable and concise.
Matching Digits: \d and \D
The pattern \d matches any single digit character (0-9). It is equivalent to the character set [0-9].
Conversely, \D (capital D) matches any character that is not a digit.