Alteryx Designer Desktop Discussions

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

REGEX Replace Help

ArtixWinterguard
6 - Meteoroid

Hello, i have a few strings that i need to be converted to a number, but it has two dots both as separator, is like a:

111.111.11

22.222.22

3.333.33

 

Im having troubles to solve this, so anyone can help me? I need to cut off this first comma on all expressions, resulting in that way:

 

111111.11

22222.22

3333.33

 

 

I`m currently using that forumula, but i dont know why this not working:
REGEX_Replace([Field1],"[0-9]*[.]*/[0-9]*[.]*[0-9]", '[0-9]*[.]*[0-9]')

6 REPLIES 6
apathetichell
18 - Pollux

regex_replace([field1],"(\d+)\W(.*)","$1$2") worked for me.

ArtixWinterguard
6 - Meteoroid

Worked for me too, but i have a larger base that has more dots, if we have 3 or more dots your formula doesnt  work, like 7.777.777.777.00
The real issue that a only need the last dot on right, the rest will error thw flow. Those vallues will be converted to a fixed decimal 18.2

mpennington
11 - Bolide

EDIT: @ArtixWinterguard  Got my solution tweaked, sorry for confusion.  Again, the solution posted by @apathetichell works well with initial question, but I would approach it differently with the new requirements.  My recomendation is to use a lookahead to replace all dots that aren't the last.

REGEX_Replace([String], '\.(?=.*\.)', '')

RegEx Dot Lookahead.jpg

shreyanshrathod
11 - Bolide

Hi @ArtixWinterguard ,

The below attached workflow should help.

 

Input :- 

shreyanshrathod_0-1622830962110.png

 

workflow :- 

shreyanshrathod_1-1622830994535.png

 

output :-

shreyanshrathod_2-1622831046305.png

 

Regards,

Shreyansh

ArtixWinterguard
6 - Meteoroid

Thank you guys! All your solutions have worked for me!

apathetichell
18 - Pollux

fyi - I'd go for replace

 

([left([field1],length([field1]-3),",","")+right([field1],3)

 

 

a.k.a the non-regex solution.

 

Labels