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 pull specific number out of string of text help

jannis005
7 - Meteor

Hello -

 

I am trying to pull out a certain portion of a file name (see example below). Can anyone help with the appropriate RegEx syntax to pull out this information, and this information only? Or if there is an alternative way other than RegEx that would be appreciated as well.

 

Thanks!

 

example string with bolded text being the text I want to extract:

V:\FY18\Connect Support\R109 summary of receivables and payables\Response Documents\3048159_1725_FA_CustomSet_KAPOLLO_924879_31-Oct-2018_05-Nov-2018.pdf

4 REPLIES 4
MarqueeCrew
20 - Arcturus
20 - Arcturus

@jannis005,

 

Did you already try this expression?

 

REGEX_Replace([Field1], ".*\\\d+_(\d+)_.*", '$1')

Cheers,


Mark

Alteryx ACE & Top Community Contributor

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

I had not but that worked. From a learning perspective, what is the significance of the \\\ in your regular expression?

MarqueeCrew
20 - Arcturus
20 - Arcturus

Excellent question @jannis005!

 

I'm glad that you asked.  

 

.*\\\d+_(\d+)_.*
the . matches any character (except for line terminators)
the * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 
\\ matches the character \ literally (case sensitive)
 
\d+
 matches a digit (equal to [0-9])
+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
_ matches the character _ literally (case sensitive)
 
1st Capturing Group 
(\d+)
 
\d+
 matches a digit (equal to [0-9])
+ Quantifier — Matches between one and unlimited times, as many times as possible, giving back as needed (greedy)
_ matches the character _ literally (case sensitive)
 
.*
 matches any character (except for line terminators)
 
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
 
If anyone ever gives you an expression, you can paste the first argument into regex101.com and it will translate the expression as it did above.  You can also go there to learn and play with expressions.
 
Cheers,
 
Mark
 
Alteryx ACE & Top Community Contributor

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

Very helpful - thanks for the insight!

Labels