I'm trying to extract date, percentage or number from string. Strings can be:
- the response value 10 (from here I want to extract 10)
- the response value 10/12/2014 (from here I want to extract 10/12/2014)
- the response value 08/2015 (from here I want to extract 08/2015)
I've written regex as (?:\d{2}\/\d{4}|\d{2}(?:\/\d{2}\/\d{4})?) Regex is satisfying 12/12/2014, 10, 02/2012.
I'm also trying to modifying same regex to get 10, 08/2015 and 10/10/2015 but not getting how to get.
How can this be achieved?


12/12/2014as you claim, to match12/12/2014, you'd need(\d{2})[\/](\d{2})[\/](\d{4})\b(?:\d{2}\/\d{4}|\d{2}(?:\/\d{2}\/\d{4})?)\bregex101.com/r/xqApkK/1 Note that 4 digits also match 9999