How to Use Regular Expressions to Retrieve the Last Two Digits of a Date?
Given text data in the following format:
event_date=2020-01-05
We can use regular expressions to retrieve the last two digits of the date (in this case, 05
).
To do this, we need to use the [a-zA-Z0-9]
wildcard character, which matches any letter or number. We can then specify that we only want the last two characters of the date.
The following regular expression should do the trick:
[a-zA-Z0-9]{2}$
This expression will match the last two characters of any string that contains only letters and numbers.