Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Community v19.6

Looks aren't everything... But the latest Community refresh looks darn good!

Learn More

Help with RegEx expression

Alteryx Partner



I'm struggling with a RegEx issue - I have a template that users are using to provide information, but sometimes the user will delete the last few lines if it doesn't pertain to them. See the template and two examples below; in t he second example, the user has deleted the Amount 2 line because it doesn't pertain to them, whereas in the first example, the user has left the Amount 2 line.





Amount 1: 

Amount 2: 



Name: John Smith

Number: 1

Amount 1: 500

Amount 2: 


Name: Jack Smith

Number: 2 

Amount 1: 600


Using the RegEx Parse expression "Name:(.+)^Number:(.+)^Amount 1:(.+)^Amount 2:(.+)" leaves anything that's like the second example un-parsed since it won't find the Amount 2 line, and I can't quite figure out how to get the expression right. I've also tried RegEx Tokenize with ":(.+)", which only gives me the output from the Name line. 


I can use the Text to Columns tool pretty easily, but wanted to try to tackle using RegEx.


Thank you in advance!

Alteryx Partner

I will want to follow this because this is an area that I struggle.


Someone recommended to me the following site:


You can test your regular expression built within this site.


Hi @jvirtanen0201 


You can try something like this


Name:(.+) Number:(.+) Amount 1: (\d+)\s{0,1}(Amount 2: (.+)){0,1} 


I wrapped the entire Amount 2 group in a capturing group and made that one optional {0,1}.  In order to get consistent results I also had to specify that the 

group 1 value was digits {\d+}










Tell me if it helps ? 

Alteryx Certified Partner
Alteryx Certified Partner

Hi @jvirtanen0201 


This could work:




Basically, each line would represent this:


you want everything after the ":\s" but until the end of each line. This whole expression can be optional, which is why we ungroup the whole thing -  (?:......)?


A little bit hard to explain, but it works really well and it doesn't give you null values because everything is optional.


Alteryx Partner

@Thableaus that worked great, thanks so much!!

Alteryx Partner

@ismailhab thanks so much, that did work!

Alteryx Partner

@danilang thank you so much, that worked!