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

Remove All Special Characters Except for a few- RegEx

vgupta8
7 - Meteor

Hi Team,

 

I have an excel file with following data. I have 2 requirement as listed below.

 

Requirement 1 - There is a column "Special Characters" which has a few values. Requirement here is I except for $, I would like to remove rest all special characters from output. If there is some alphabet or numeral, then I could like to keep that as is. Please refer column "Expected Output - Requirement 1" in table below.

 

Requirement 2 -  Slight modification from the requirement 1. Except for $ and #, I would like to remove rest all special characters from output. If there is some alphabet or numeral, then I could like to keep that as is. Please refer column "Expected Output - Requirement 2" in table below.

 

I tried achieving this through RegEx tool, but could not. Any help in this regard is highly appreciated.

 

Thanks in advance.

 

Special CharactersExpected Output - Requirement 1Expected Output - Requirement 2
$%$%$$$$
%^%^  
&(*^(^  
#$%#&%&*$#$#
@$%#^56$56$#56
%&*&^  
123&*&123123
vsg45%#^vsg45vsg45#
ddfr66#ddfr66ddfr66#

 

Regards

2 REPLIES 2
MarqueeCrew
20 - Arcturus
20 - Arcturus
Try using not in the list of characters as the replacement target.

Regex_replace([field],"[^a-zA-Z0-9\$]",'')

Cheers,

Mark

Ps. You can include other acceptable characters. Because $ is a reserved character I precede it by \. The # character can be added without concern.
Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
vgupta8
7 - Meteor

Thanks a ton for the quick response, Mark. This works for me.

Labels