Alteryx Designer Desktop Discussions

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

RegEx replace 3 character string with blank

shelbyswartz
6 - Meteoroid

I am trying to use Regex to recognize the strings with 3 characters and replace them with nothing. Example,"IDC". What would be the syntax for this?

5 REPLIES 5
Luke_C
17 - Castor

Hi @shelbyswartz 

 

Assuming you want to replace any instance of IDC and leave the rest of the string intact: In a formula tool, something like REGEX_Replace([Field1], 'IDC', '') should work. In the regex tool the below screenshot's configuration will do the same thing as the above formula. 

 

A non-regex solution would be: replace([Field1],'IDC','')

 

Luke_C_0-1620944986904.png

 

shelbyswartz
6 - Meteoroid

I actually need to identify any string that's 3 characters and not just IDC.

Luke_C
17 - Castor

Ah, sorry I misread. Is there any reason you want to use regex rather than a formula like the one below that checks the length? 

 

if Length([Field1]) = 3 then '' else [Field1] endif

 

apathetichell
18 - Pollux

 

This is a length of 3 or 3 letters in a string of numbers?

 

If the latter than:

if REGEX_Match([test],".*[a-z]{3}.*") then "" else [test] endif will work for you.

 

if more than 3 is an option {3} should be {3,}

 

shelbyswartz
6 - Meteoroid

Thanks Luke!

Labels