Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

RegEx with dynamic/varying length

DanAAC
7 - Meteor

Hi all,

 

I need to parse a long string that has some fixed and variable characters. 

For the fixed characters, I use (\w{#}), but for the variable characters I am looking for a solution.

 

For example, all the characters in the following string are fixed, except for the red characters, which can vary from 1-24 characters (including white spaces).

 

XXXX XXX X X X XXXXXXXXXXXXXXXXXXXXXXXX XX XX XX XXXXXXXX XXXXXXXX XXXXXX

 

Would appreciate any assistance! 

4 REPLIES 4
Carlithian
11 - Bolide
11 - Bolide

If the black characters are always consistent, and assuming the leading there are 8 leading characters and 16 trailing characters something along these lines should work 

Right(Left([Code],Length([Code]) - 16),Length([Code]) - 24)

Here is a breakdown of the steps :)

Length([Field]) - 16

 

this will give you the length of the red characters and the leading characters

Left([Field], Length([Field]) - 16)

adding that to left will return the leading and the red characters

Right([Field], Left(Length([Field]) - 16),  Length([Field]) - 24)

stacking that with a right, will just bring out the red characters


Happy Alteryxing
binuacs
21 - Polaris

@DanAAC Can you provide a sample data?

DanAAC
7 - Meteor

Thank you!

 

I am not sure this is what I am looking for. I am going to parse the ENTIRE string, not just the string in red. But the string in red is not fixed.

I am using RegEx to parse the string into columns.

DanAAC
7 - Meteor

@binuacs 

 

Please see attached. It's essentially the same as in my original post. But I am using RegEx to parse one column that contains a string into multiple columns. The only problem is that the part in red is not fixed.

Labels
Top Solution Authors