Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Regex to pull leading numbers with varying lengths and delimiters?

TGow
5 - Atom

Howdy,

 

Tried searching the boards for a similar issue and don't see one that is similar to this. Hoping someone can assist as I'm a Regex newbie.

 

I basically have a bunch of support documents that have a identification code up front followed by the name of the support. These codes can vary in length and the characters that follow the digits can also vary. Here's a rough example:

 

File naming conventionsWhat I need to pull
3340-Balances-202012043340
700132099  SupportPackage700132099
8129005_12-04-2020 Module8129005
32603260CashValues32603260

 

All I'm after are the codes at the front. I'm having a heck of a time with this as my trusty ol' text to columns doesn't seem to work super well when the delimiter can be an underscore, space, hyphen, or not exist at all. Any thoughts?

 

Thanks in advance, friends!

5 REPLIES 5
Qiu
20 - Arcturus
20 - Arcturus

@TGow 
How about this one?

Capture.PNG

treepruner
9 - Comet

I think (\d+) which looks for any amount of digits in the front of the field and puts it into a new column will do what you need:

 

treepruner_0-1607125195432.png

 

 

This RegEx editor site   

is really helpful with POSIX regex syntax.

 

Sarah

MarqueeCrew
20 - Arcturus
20 - Arcturus

Here's a quick formula:

 

regex_replace([field],"(\d+)\D.*","$1")

 

 starting numbers get caught. 

cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
TGow
5 - Atom

Hi all, these all look like they'll work!

 

Thank you Qui and treepruner for the regex tool examples, it looks like the solution is fairly simple! I definitely need to spend some time learning this a bit more. In that vein, thank you for the link treepruner. I will give it a look!

 

Thank you for the formula MarqueeCrew. I knew the formula tool can do a lot of Regex magic but have never given it a shot. I'll definitely look at ways to try and integrate these in my workflows once I have a better handle on the subject.

 

I appreciate you all taking the time to assist 😀

MarqueeCrew
20 - Arcturus
20 - Arcturus

Thanks for the opportunity that you gave us to help show you alternative ways of solving using Alteryx. 

cheers,

 

 mark

Alteryx ACE & Top Community Contributor

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