I want to match some sub-string like date in month as “21st” or “22nd” or “23rd” in a string, so I made a regular expression using this pattern:
((\d{1,2})(st)|(nd)|(rd)|(th)).
I made these group because I want to do replace. But when I match some string like “Monday March 21st 2012”, it always matches two sub-string: Mo’nd’ay March ’21st’ 2012.
So I am confused why it matches “Mo’nd’ay”?
Because you have a missing set of parenthesis. Try:
What you had, matched: