Alteryx Designer Desktop Discussions

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

regex match to find the middle string

jlvi
5 - Atom

Hi there,

 

i have a simple workflow here that  I am trying to extract the middle two digit as shown in the table below.

 

I been using regex_match([AM],'\.\d{2}\.',1) in the formula tool to do the extraction however it keep returning me 0 as shown below. Please do let me know where did I made the mistake in the regex. 

 

I had attached the workflow for reference. I do understand that i can opt to perform the extraction easily with text to column tool. However , i do have my reason why I would prefer to use formula tool instead as part of my larger workflow. Also , i would need to keep the [AM] column as string, hence i could not opt to convert to date format and extract the month instead. 

 

Returned.JPGexpected outputexpected output

 

 

 

 

 

 

Thanks.

5 REPLIES 5
alexnajm
17 - Castor
17 - Castor

SubString([AM],3, 2) should work! RegEx Match is only going to give you if it matches or if it doesn't

jdminton
12 - Quasar

If you're trying to extract the middle two, you would need to use Regex parse, which requires the regex tool. You can do a formula without regex as well. Substring([AM],3,2) to extract this if this is always the format. For Regex parse, you would use "\d{2}:(\d{2}):\d{4}.*". Again that would always need to be the pattern.

jdminton
12 - Quasar

@alexnajm  I wish there was a way for pages to update with additional comments without having to refresh my browser!

jlvi
5 - Atom

Thanks both!

both methods works for me really thanks alot!

alexnajm
17 - Castor
17 - Castor

Agreed @jdminton !

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels