Reputation: 2095
I want to check if a file name contains a date pattern (dd-mmm-yyy
) in it using if condition
activity in Azure Data Factory. For example: The file name I have is like somestring_23-Apr-1984.csv which has a date pattern in it.
I get the file name using Get Metadata
activity and passing it to the if condition
activity where I want to check if the file name has the date pattern in it and based on the result I would like to perform different tasks. The only way I know to do this is by using regex to check if the pattern is available in the file name string but, Azure does not have a regex solution mentioned in the documentation.
Is there any other way to achieve my requirement in ADF? Your help is much appreciated.
Upvotes: 0
Views: 3272
Reputation: 8660
Yes,there is no regex in expression.There is another way to do this,but it is very complex.
First,get the date string(23-Apr-1984) from the output of Get Metadata
.
Then,split the date string and determine whether each part match date pattern.
Below is my test pipeline:
First Set variable
:
name: fileName
value: @split(split(activity('MyGetMetadataActivity').output.itemName,'_')[1],'.csv')[0]
Second Set variable
:
name: fileArray
value: @split(variables('fileName'),'-')
If Condition
:
Expression:@and(contains(variables('DateArray'),variables('fileArray')[0]),contains(variables('MonthArray'),variables('fileArray')[1]))
By the way,I want to compare date with 0 and 30 originally,but greaterOrEquals()
doesn't support nested properties.So I use contains()
.
Hope this can help you.
Upvotes: 3