Hi all
I try to use the regex_match formula to get the needed data.
I have following data as example
source1 | mapping1 |
ASW-xyz | ASW- |
C9300-24P-E | 24P-E |
and I use following Regex_match
if REGEX_Match([source1],[mapping1]+'.*') then "OK" else "NOK" endif
For row1 I get a OK but for row2 I get a NOK.
Can someone please tell me what I do wrong, and what is the correct regex to match not only the characters at the begining?
Many thanks
Steffen
Solved! Go to Solution.
@chvizda use the Contains() function instead of regex
IIF Contains([source1],[mapping1]) ,"OK" else "NOK")
@chvizda Contains() is the better option here. But to answer your question, the correct expression would be:
if REGEX_Match([source1],'.*'+[mapping1]+'.*') then "OK" else "NOK" endif
In your original, you only had a '.*' after the set string and so you're asking Alteryx to look for values that start with mapping1 and then contain zero or more of any other characters, which satisfies the first record but not the second. By adding another '.*' at the start, you're then telling Alteryx to look for one or more of any character - then mapping1 - then zero or more of any character again, which satisfies both records.