Start Free Trial

Alteryx Designer Desktop Discussions

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

Finding codes starting with specific characters in a string with Regex

FabioP
8 - Asteroid

Dear all,

 

Can some one help me to improve the Regex expression to solve the issue below:

 

FabioP_0-1683718668982.png

 

I'd like to have the line 5 with the same quantity of character of above ones (only 8 characters)...

What do I need to do in my expression to achieve this?

8 REPLIES 8
gautiergodard
13 - Pulsar

hello @FabioP 

One way to do this would be with a formula tool, and using the following:

 

 

PadLeft([RegExOut1], 17, 'X')

 

 

Hope this helps!

DataNath
17 - Castor
17 - Castor

@FabioP is it always XX<Number><5 more characters> that you're looking for? Something like this will do if so:

 

(XX[^X]\w{5})

 

DataNath_0-1683721225285.png

 

If not, can you provide the exact pattern you're looking for/expecting and more variations of incoming values?

jrgo
14 - Magnetar

Give this a shot...

 

.*?(X{1,2}[^X]\w{5})
FabioP
8 - Asteroid

Hi @DataNath 

 

Could you send your file to me?

FabioP
8 - Asteroid

Hi @jrgo

 

It worked!! -> .*?(X{1,2}[^X]\w{5})

 

Could you explain to me the ? and the {1,2} functions?

DataNath
17 - Castor
17 - Castor

@FabioP sure!

jrgo
14 - Magnetar

Hi @FabioP 

Glad to hear!

 

Sure, that part is saying that it should match an X 1 or 2 times. I added that because I saw that one of your examples only had one X. If it should ALWAYS match on 2 X's, then adjust it to X{2}, which is the same as XX.

RobertOdera
13 - Pulsar

Hi, @FabioP 

 

Perhaps rather than a complex regex, consider adding a formula tool after the Regex Tool with the following treatment:

Right([RegExOut1],8)

 

Regex Tool - parse - ([X]+\w{6})

Formula Tool - update RegExOut1 field with - Right([RegExOut1],8)

 

I hope you find this helpful - Cheers!

 

Labels
Top Solution Authors