Alteryx Designer Desktop Discussions

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

RegEx_Replace

olehr
8 - Asteroid

Hi there, 

 

I am quite new to regex and coding, and alteryx in general, so I ask the community for some help :)

 

I have a field containing 11 digit numbers.  However, I would like to replace the 5 last digits with X as these digits represent personalized ID numbers. 

So lets say I have this number "123456789123", but i want it to becoem 123456XXXXX

 

I have tried:      RegEx_Replace ([field1], "\d{11}", "\d{6}\wXXXXX"),  this did not work. 

 

I would appreciate any help I could get :)

 

Kind regards

 

4 REPLIES 4
jdunkerley79
ACE Emeritus
ACE Emeritus

Try:

RegEx_Replace ([field1], "(\d{6})\d{5}", "$1XXXXX")

This will match 11 numbers in a row and save the first 6 into $1.

It will then replace all 11 with the first 6 then 5 Xs

olehr
8 - Asteroid

Thank you so much, that worked perfectly :)

 

However, one question. You started with "(   Why the quote outside the parenthesis? And for that matter, why the parenthesis in the first place ?  

 

Stupid question from a nubie :p

 

Kind regards

jdunkerley79
ACE Emeritus
ACE Emeritus

The parenthesis identifies a marked group. These get stored in the $1, $2, ... variables

 

Take a look at regexr for more explanation.

olehr
8 - Asteroid

Thank you.

Labels