Updated: 2016-02-05-Fri 04:13:21 UTC
The Digits class (\d):
Note: The digits class includes 0-9; however, it also includes the digits of other numeral systems for Unicode-configured sysetms (e.g., the chinese numerals: 一,二,三, etc.). The non-digits class is the compliment to the digits class (everything in the configured character set except digits). |
||
---|---|---|
# | REGEX Pattern: |
|
01. | /\d/ |
|
02. | /\d/ |
|
03. | /\d/ |
|
04. | /\d/ |
|
05. | /\d./ |
|
06. | /^\d/ |
|
07. | /\d\d/ |
|
08. | /.\d/ |
|
09. | /\d\d./ |
|
10. | /\d\d.?/ |
|
11. | /\d*/ |
so it simply accepts a match of 0 digits. This might seem contrary to to the notion of greediness (i.e., you'd assume it would match at least one digit further down the string, but it likely doesn't because this would just be more runtime (and why waste time when it can match 0). |
12. | /\d\d*/ |
so it moves on and matches the first digit on the '3', then for the second digit, it simply accepts a match of 0 digits. This might seem contrary to the notion of greediness (i.e., you might wonder if it would try for a 'better' match at '14', but it likely doesn't because this would just be more runtime (and why waste time when it can match 0 digits for the second digit (\d*). |
13. | /\d\d?/ |
not match where you might expect it to later in the string. |
14. | /\d+/ |
|
15. | /\d\d|\d/ |
|
16. | /\d|\d\d/ |
|
17. | /\D/ |
|
18. | /\D\D/ |
|
19. | /\D\D?/ |
|
20. | /\D\d/ |
|
21. | /\d\D/ |
|
22. | /\d\d\D/ |
|
23. | /(\d\d\D)?/ |
|
24. | /\d\d?\D/ |
|
25. | /(\d\d)?\D/ |
|
26. | /^\d\D/ |
|
27. | /\D$/ |
|
The Word class (\w):
Note: TODO |
||
---|---|---|
# | REGEX Pattern: |
|
01. | /\w/ |
|
02. | /\w+/ |
|
03. | /\w*/ |
|
04. | /\w\w*/ |
|
05. | /\w*\w/ |
|
06. | /\w+\w/ |
|
07. | /\w+\d/ |
|
08. | /\d\w/ |
|
09. | /\w\D/ |
|
The word bounday and non-word boundary classes (\b & \B):
Note: |
||
---|---|---|
# | REGEX Pattern: |
|
01. | /show\b/ |
|
02. | /\sshow/ |
|
03. | /\b\d{4}/ |
|
04. | /\b\d{4}\b/ |
|
05. | /\b\d.*/ |
|
06. | /\B\d.*/ |
|
07. | /\b\d.*\b/ |
|
08. | /\s\d\b/ |
|
09. | /\s\w+\b/ |
|
10. | /\b\d*\b/ |
|
11. | /\b\d+\b/ |
|
12. | /\b\w*\b/ |
|
13. | /\b\w+\d+\b/ |
|
14. | /\b\w\d\d\w*\b/ |
|
15. | /\bhow\b/ |
|
16. | /\bshow\b/ |
|
17. | /\bshow/ |
|
18. | /show\b/ |
|
19. | /\bthe\b/ |
|
20. | /the\b/ |
|
21. | /\bthe/ |
|