Start Free Trial

Alteryx Designer Desktop Discussions

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

Parsing string in REGEX expression

namitajuneja
6 - Meteoroid

Hello All,

 

I would like to write a REGEX replace or substring function in Alteryx but I am struggling hard.

 

Condition: Wherever it sees 3rd dot in the string, It should eliminate the string after it.

Example shown below

 

My input data looks like

 

Id.2.7.1

Id.2.7.2

Id.2.7.3

Id.3.1

Id.3.2

 

Output data should be

Id.2.7

Id.2.7

Id.2.7

Id.3.1

Id.3.2

 

Thanks

4 REPLIES 4
binuacs
21 - Polaris

@namitajuneja One way of doing this

binuacs_0-1661858489788.png

 

IraWatt
17 - Castor
17 - Castor

Hey @namitajuneja,

Bit of a scary looking regex match but this works:

([^.]+\.[^.]+\.[^.]+)

It matches with one or more non . characters, then a . then one or more non . then a . one or more non . characters. Or to put it another way:

[^.]+

Captures everything before a point

\.

Captures a point.

IraWatt_0-1661858759037.png

If you want to learn more about Regex the community has some really quick interactive videos on getting to grips with it here https://community.alteryx.com/t5/Interactive-Lessons/tkb-p/interactive-lessons/label-name/Parsing%20...

 

Any questions or issues please ask

Ira Watt
Technical Consultant
Watt@Bulien.com 

 

 

 

DataNath
17 - Castor
17 - Castor

If you wanted to avoid RegEx then you could go down a route like this. The number conversion automatically trims anything off after the first 'decimal' as it reads it here. This approach is obviously only appropriate if your ID numbers follow similar format to what you have provided in the example.

 

DataNath_0-1661859199210.png

namitajuneja
6 - Meteoroid

Thank you so much. 

 

It was very helpful.

 

Labels
Top Solution Authors