Complete the code to define a named capture group called 'year' in the regex.
regex = /(?<[1]>\d{4})/ # Matches a 4-digit year
? syntax.The syntax (? defines a named capture group called 'year' that matches 4 digits.
Complete the code to access the named capture 'month' from the match data.
match = /(?<month>\d{2})/.match('07')
month = match[:[1]]You access named captures from a MatchData object using symbols like match[:month].
Fix the error in the code to correctly define and use a named capture 'day'.
regex = /(?<[1]>\d{2})/ match = regex.match('15') day = match[:day]
The named capture group must be called 'day' to match the symbol used to access it.
Fill both blanks to create a regex with named captures 'year' and 'month' and access them.
regex = /(?<[1]>\d{4})-(?<[2]>\d{2})/ match = regex.match('2023-06') year = match[:year] month = match[:month]
The regex defines named captures 'year' and 'month' to match the parts of the date string.
Fill all three blanks to create a regex with named captures 'year', 'month', 'day' and access them.
regex = /(?<[1]>\d{4})-(?<[2]>\d{2})-(?<[3]>\d{2})/ match = regex.match('2023-06-15') year = match[:year] month = match[:month] day = match[:day]
The regex uses named captures 'year', 'month', and 'day' to extract parts of the date string.