We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

RegEx Parsing question

szwgl2022
7 - Meteor

Hello,

 

I am pretty new to RegEx tool and want to extract the second four-digit in the below string with RegEx.

 

For example, need "3331" in the blow string:

 A:\Bbbb\Cccc\2019\No&Disc\1. In_Out basis \3331 Out Bas Calc.xlsx

 

Thanks!

Way

6 REPLIES 6
IraWatt
17 - Castor
17 - Castor

Hey @szwgl2022,

Heres one of the ways to do that

IraWatt_0-1653662533404.png

The regex below matches against some characters then 4 digits then some characters and finally then looks for our group of 4 digits after that

 

 

.+\d{4}.+(\d{4})

 

 

I'd recommend regex101: build, test, and debug regex for learning and practicing

Any questions or issues please ask :)
HTH!
Ira

binuacs
21 - Polaris

@szwgl2022 One way of doing this

 

binuacs_0-1653662788141.png

 

MarqueeCrew
20 - Arcturus
20 - Arcturus

@szwgl2022 

 

.*(\d{4}).*

is greedy.  It finds the last 4 digits.  

cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
szwgl2022
7 - Meteor

Thank you all for the help! :)

szwgl2022
7 - Meteor

Hi @IraWatt , thanks a lot for your help! There are some of the strings in the same field have a letter or two right after the four digits I need. How do you modify the regex to parse the four digits with the letters?

for example, need to parse out "3331A" and "3331BC"

A:\Bbbb\Cccc\2019\No&Disc\1. In_Out basis \3331A Out Bas Calc.xlsx

A:\Bbbb\Cccc\2019\No&Disc\1. In_Out basis \3331BC Out Bas Calc.xlsx

MarqueeCrew
20 - Arcturus
20 - Arcturus

.*(\d{4}\u*\b).*

is greedy.  It finds the last 4 digits and includes any letters. 

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels
Top Solution Authors