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.

Regex

Sarath27
8 - Asteroid

Hi All,

 

Could you please help me writing regex to bring Column "Type" based on ID?

 

IDType
912828B0GC
10054816GC
CORPHYGCSP
5 REPLIES 5
Deano478
12 - Quasar

@Sarath27 how are you assigning the Type based on the ID?

jdminton
12 - Quasar

@Sarath27 I think I know what you are asking, but if we are to identify the type based on the number and letter patterns, I'm thinking we will need many more examples. A set of 3 does not provide much variety. If it either starts with a number or a letter and those are the only 2 options, you can even use a formula tool with:

IF IsNumber(Left([ID],1))
THEN "GC"
ELSE "SP"
ENDIF

 

For RegEx, you would need to use match and then populate the value in another column (or replace if you no longer need the ID data. For RegEx match "\d.+"  would identify the strings starting with a number.

Raj
16 - Nebula

@Sarath27 can you explain the logic behind adding Column Type.

flying008
15 - Aurora

Hi, @Sarath27 

 

Like this ?

IIF(REGEX_Match([ID], '[a-z]+'), 'SP', 'GC')

 

录制_2024_05_31_10_58_57_187.gif

 

jdminton
12 - Quasar

@flying008 that will only work if all of the characters in the SP type are letters. If they start with letters but include a number, it will consider it SP. This is also why I asked for more examples or logic from @Sarath27 

Labels