Alteryx Designer Desktop Discussions

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

Regex to remove special characters

DataIsFun
7 - Meteor

Hi community Happy new year,

 

I'm not to good with RegEx but I know it is needed in my use case. I have these company names but they contain special characters and i'm not sure how to remove them. I've attached  a mini dummy sample of the data below. 

 

Any assistance with this would be majorly appreciated 

 

Name
Test Company 1 –Limited
Test Company 2’s Ltd
O’Test Hotel Limited

 

7 REPLIES 7
FinnCharlton
13 - Pulsar

Try REGEX_Replace([String],"[^a-z,A-Z,0-9,\s]","")

 

This gets rid of all characters that are not special letters, spaces or numbers.

binuacs
21 - Polaris

@DataIsFun One way of doing this

 

binuacs_0-1672918280280.png

 

Deano478
12 - Quasar

@binuacs I saw your solution and I'm just wondering how does your Regex work? ðŸ˜€

 

binuacs
21 - Polaris

@Deano478the regex formula 

REGEX_Replace([Name], '[^ -~]', '')

 

Remove any characters from the incoming field that are outside of the range of ASCII values from "space" to "~".

^ - represent the not operator 

<space> - ~  characters with in the range space and ~

 

Below is the ASCII table where you can see the range 32(space) - 126(~), so any characters that fall other than this range will get replaced with ''

 

binuacs_0-1672922109012.png

 

 

 

Deano478
12 - Quasar

@binuacs that's actually very interesting to read I will definitely read more into regex to get more comfortable with it myself it seems very powerful when used the right way. 

malcorr
8 - Asteroid

hello, i like this solution but i want to apply it in a text field that contains text in japanese, chinese and korean. How can i address that as well?

binuacs
21 - Polaris

@malcorr If you want to include the Japanese, Chinese, and Korean then find their corresponding ASCII characters and include those also in the regex expression, if you can provide some samples I can help you with this.

Labels
Top Solution Authors