Reputation: 837
I have a dataset that contains dates and string together. I want to extract the date then save it in a date
column and string in the task
column. I am using azure data flow to achieve this data transformation.
regexExtract({Finish Date Activity}, '^([0-2][0-9]|(3)[0-1])(\-)(((0)[0-9])|((1)[0-2]))(\-)\d{4}$', 1)
But this does not seem to work for me and getting Unable to parse the expression. Please make sure it is valid.
error. Can anyone help me to solve this, please?
Upvotes: 1
Views: 682
Reputation: 626748
You may use
((?:0?[1-9]|[12][0-9]|3[01])-(?:0?[1-9]|1[0-2])-\d{2}(?:\d{2})?)
Or, if your dates are always at the start of the text:
^((?:0?[1-9]|[12][0-9]|3[01])-(?:0?[1-9]|1[0-2])-\d{2}(?:\d{2})?)
See the regex demo
Details
^
- start of string(
- start of a capturing group #1 (you extract this group value with 1
argument)(?:0?[1-9]|[12][0-9]|3[01])
- a non-capturing group: day value-
- a hyphen(?:0?[1-9]|1[0-2])
- month part-
- a hyphen\d{2}(?:\d{2})?
- two- or four-digit year.Upvotes: 3