Alteryx Designer Desktop Discussions

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

Replace . with , and , with dot

JDong
8 - Asteroid

Hi All,

 

Maybe trivial but I am not able to get the solution 🙂

 

I have the following data

 

372.742,00 $
10.241,00 $
355.295,00 $
7.206,00 $
65.480,00 $
65.480,00 $

 

I want to replace the . with , and , with .

 

Expected result is 

 

372,742.00 $
10,241.00 $
355,295.00 $
7,206.00 $
65,480.00 $

 

Any way  to achieve this result within a calculation like replace ?

 

Using 2 replaces updates all instances

8 REPLIES 8
apathetichell
18 - Pollux

regex replace with marked groups...

 

regex tool..

replace mode.

formula:

(\d+)\.(\d+),(.*)

 

In the replace text field:

$1,$2.$3

mpennington
11 - Bolide

I think this should work for you:

 

REGEX_Replace([Data], '(.*)\.(.*),(.*)', '$1,$2.$3')

 

Regex2.jpg 

JDong
8 - Asteroid

Thanks how about in the opposite scenario...how can I change the regex ?

 

372,742.00 $
10,241.00 $
355,295.00 $
7,206.00 $
65,480.00 $

 

 

Expected output

 

372.742,00 $
10.241,00 $
355.295,00 $
7.206,00 $
65.480,00 $
65.480,00 $

 

apathetichell
18 - Pollux

same regex formula exactly - just swap the position of the "\." and the ","

 

Note my regextool and @mpennington 's regex_replace formula version should work identically and both should be able to solve your problem. There is slightly different syntax (mine requires digits, and his will work with any characters) but both should do great for your situation.

JDong
8 - Asteroid

Thanks and is a easy way to generate such regex for specific use cases ? 

apathetichell
18 - Pollux

The best way to learn regex is to use it on a regular basis - but for starters the Alteryx training videos under Learn are super useful as are some of the Weekly Challenges which recommend it...

AdamR_AYX
Alteryx Alumni (Retired)

And here is a non RegEx solution

 

Replace(Replace(Replace([Field1],
",", "¬"),
".", ","),
"¬", ".")

 

Replace the , with a random character

then replace . with ,

then finally random character to .

Adam Riley
https://www.linkedin.com/in/adriley/
ChrisTX
15 - Aurora

easy way to generate such regex....

 

Generally, RegEx is not "easy".  It's a skill you improve over time.  Try this website to test expressions:  regex101.com

 

Chris

Labels