Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Extract Date from Text

iteng
6 - Meteoroid

Hello,

 

I'm new to Alteryx and slowly developing my skillset. I'm trying to extract year information from text (for example "XXX - Year 2020" and "XXX - Year 2020-2022") to a new column. I'm trying out the RegEx function and want to write something that helps put information after "-" or word "year" into a new column, but having some trouble entering the correct regular expression. Any solution or suggestions would be much appreciated!

4 REPLIES 4
IraWatt
17 - Castor
17 - Castor

Hey @iteng,

This regex will get anything after a -

 

-(.*)

 

This regex will get anything after year

 

year(.*)

 

If you wanted to identify any 4 digits use this

 

\d{4}

 

For this problem I would use something like

 

year ([\d-]+)

 

IraWatt_0-1654899835219.png

Check out regex101: build, test, and debug regex to learn more about and test regex.

Any questions or issues please ask :)
HTH!
Ira

 

iteng
6 - Meteoroid

This is super helpful. Thank you so much for your help!

Qiu
21 - Polaris
21 - Polaris

@iteng 
You will love the regex once you get to know it a bit more like me. 😁

@IraWatt gives good details which I really love it.
I would like to introduce a few links from the Knowledges Database, in case you have not noticed.

https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/Tool-Mastery-RegEx/ta-p/37689

https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/RegEx-Examples-12-Handy-Use-Cases/t...

https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/20-Token-RegEx-Expressions-For-The-...

IraWatt
17 - Castor
17 - Castor

Thanks @Qiu ! 😄 Completely agree once you start using Regex its actually quite good fun 😅

Labels
Top Solution Authors