Can anyone please let me know the regex code to enter digit(1 to 31) followed by one single character for example: 2d or 3d. The character will always remain 'd' or 'D' and number can be any number from 1 to 31. Basically this denotes 2 days or 3 days.
Asked
Active
Viewed 208 times
1 Answers
1
StackOverflow is not a homework service.
But here you go...
\b(?:3[01]|[12][0-9]|[1-9])[dD]\b
You can use http://regexr.com to test out regular expressions easily.
(Improved by Biffen)
-
I'm pretty bad with regex and tend to avoid it so this definitely isn't the best example. I just provided something that works. Will fix and add disclaimer. :) – byxor Aug 16 '16 at 11:46
-
2