Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

How to eliminate a character/space between 2 single letters using Regex_Replace?

morioren
6 - Meteoroid

Hello,

I am trying to eliminate a single space or a character between 2 single letters using Regex:

For example: S P SERVICES  or:  S & P SERVICES

How do I get to: SP SERVICES using the Regex_Replace formula?

Thanks!!

5 REPLIES 5
ivoller
12 - Quasar

See attached. Regex matches for word characters separated by space OR non word character.

 

2018-09-13_23-39-09.png

morioren
6 - Meteoroid

Thanks so much!

I am looking for something that works for ANY space/characters between single letters.

So if i have I B M  or:  SERVICES S P SERVICES

will the same formula eliminate the spaces between those single letters as well to get to:

IBM

SERVICES SP SERVICES

 

Not sure if it is possible to achieve such thing using Regex..

 

Thanks again!

ivoller
12 - Quasar

It gets a bit tricky when we don't know how many to cater for AND we have to worry about non-word characters between single characters. The attached will deal with the examples you mentioned. It may be easier to deal with 'char space char' separate form 'char special char' cases

 

2018-09-14_0-06-02.png

ivoller
12 - Quasar

I think we can do it with suitable look ahead/behind logic. Something like the attached.

 

2018-09-14_0-23-18.png

morioren
6 - Meteoroid

wow. that works! thank you very much

Labels