Alteryx Designer Desktop Discussions

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

String pattern for multiple field

fomenter
8 - Asteroid

Hi,

 

I have a list of fields; name,address,phone number,social security number, and I want to do pattern analysis; Replacing all letters with A, all numbers with 9. I can do pattern analysis on individual fields by applying regex for each. However, I would like to have a single function/formula that can do pattern analysis for all fields. Is it doable or do I need to apply regex for each field

 

Thanks

5 REPLIES 5
MarqueeCrew
20 - Arcturus
20 - Arcturus

@fomenter,

 

  1. Make sure that all incoming fields are a TEXT data type.
  2. Use a Multi Field formula and select the desired data fields.

 

regex_replace(
regex_replace([_CurrentField_],"\d",'9'),"[[:alpha:]]",'A')

This will replace all digits with the number, '9' and then will replace all alpha characters with the letter 'A'.

 

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
datadog
5 - Atom

Hi Mark - I am new to Alteryx.

 

Do you know if there is a function that can rename/replace multiple fields in 1 column through regex.

 

I tried dynamic rename and replace but cant do it on multiple values in one column. Tried through formula but it didn't work.

 

REGEX_Replace([Job Title], 'Administrative Support 6', 'Goose') OR
REGEX_Replace([Job Title], 'Technologies 5', 'Geek')

 

Thanks so much

DD

sergeyzh
5 - Atom

@MarqueeCrew 

Could you please clarify how this code works for applying one regex to multiple columns within the Multi-field formula?

 

regex_replace(
regex_replace([_CurrentField_],"\d",'9'),"[[:alpha:]]",'A')

Thank you!

MarqueeCrew
20 - Arcturus
20 - Arcturus

This is a nested expression.  The inside expression gets executed first. 

regex_replace([_CurrentField_],"\d",'9')

This takes the current field and replaces any digit "\d" with the character "9". 

the outer expression then replaces any alpha character [A-Z] or [a-z] with the letter "A".

 

 Cheers,

 

 Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
sergeyzh
5 - Atom

@MarqueeCrew  Thank you for your reply!

I get this - the sequence of replacements for a specified field. However, how can we use this approach for multiple fields at once?

For example,

Replace(Column 1, ",", "")

Replace(Column 2, ",", "")

Replace(Column 3, ",", "") etc.

Thanks!

Labels