Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Regex_match only works for characters at the beginning

chvizda
8 - Asteroid

Hi all

I  try to use the regex_match formula to get the needed data.

 

I have following data as example

 

source1mapping1
ASW-xyzASW-
C9300-24P-E24P-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

 

2 REPLIES 2
binuacs
21 - Polaris

@chvizda use the Contains() function instead of regex

 

IIF Contains([source1],[mapping1]) ,"OK" else "NOK")

DataNath
17 - Castor
17 - Castor

@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.

Labels