community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

Regex parse substring starting with a specific pattern and specific length

Hi All, 

 

Need help to parse a sub-string CW2342986 from string below. 

Always starting with CW and followed by 7 digits. 

 

"Please sign_CW2342986License Document"

 

Thanks 

 

Alteryx
Alteryx
Hi You could do this with 2 tools; Text to columns and split on delimiter of '_', then from your new field, if you add a formula tool with the formula Left([Field], 9), which will take the 2 CW characters + the 7 numeric digits. Regards Will
Asteroid

I was just going to suggest this if the CW always follows the _ 

 

Are they all the same naming convention?

Asteroid

Or using the same logic with the two tools you could always use the C as the Delimeter

 

In your formula you would then do C + LEFT([Field1],8) which will put the C back onto the number you want

Meteor

Hey if you would like to use the RegEx tool:

 

-Select the field

-Regular expression:  (CW\d+)

-output method=parse

 

This will capture the CW and any following digits.

No. The data on either side of "CW2342986" could be different every time 

This works. (Regular expression:  (CW\d+))  Can we specify the number of digits following CW to 7 

Meteor

You got it!

 

Change it to (CW\d{7})

Labels