Alteryx Designer Desktop Discussions

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

Regex Matching anywhere within a field, and within a number of characters

R_L
7 - Meteor

Hello,

 

Need a little help with my Regex Matching:

 

I have a field with records similar to these:

CODE US1325CITI141414 COA 51051851
CODE US4151EX5252
CODE GB1111

FTP CODE XC1314175

 

I want to do a regex match for the above, so that if are there any instances of: CODE[Space][ISO Code of 2 Letter Characters][Minimum of 0 to 32 Characters of Letters and Numbers] appearing in the above will match.

 

So for above:

CODE US1325CITI141414 COA 51051851 - Will Match
CODE US4151EX5252 - Will Match
CODE GB1111 - Will Match

FTP CODE XC1314175  - Will Match

CODE 1314 - No Match

FTP CODE 1721 - No Match

 

Tried the following but doesn't seem to work:

if REGEX_Match([Field1], "\w*\d*\s*CODE\s\u{2}\w{0-32}") then "Match" else "No Match" endif

 

Any help on where I can improve the above code?

 

1 REPLY 1
mattreynolds
9 - Comet

Made a few tweaks. 

 

Key things were including spaces in the 0-32 digit code match (to cover the case " COA "), and tweaked the syntax. 

 

Formula is here and example is attached:

if REGEX_Match(Input, "(\w|\s)*?CODE\s\u{2}(\w|\s){0,32}") then "Match" else "No Match" endif

 

Thanks!

Matt

Labels