I am looking for a regex which can match both the date strings. I am having trouble with specifying the ‘or’ expression: /\d{4}-\d{2}-(XX|\d{2})/ doesn’t work as it returns only the XX part:
"2007-01-XX 2008-01-01".scan(/\d{4}-\d{2}-XX/)
["2007-01-XX"]
"2007-01-XX 2008-01-01".scan(/\d{4}-\d{2}-\d{2}/)
["2008-01-01"]
Use a non-capturing group of the form
(?:...)instead of a capturing group of the form(...). So: