Link to home
Start Free TrialLog in
Avatar of Churamani Amgain
Churamani Amgain

asked on

How to remove any special character from a string if it is not part of the below "x character set"

How to remove any character from a string if it is not part of the below "x character set" .
Remove a character from a given string -if it is not part of the below x character set.
X character set: After removing the character there should not be any space on the character that gets removed.
---------------------
a b c d e f g h I j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
0 1 2 3 4 5 6 7 8 9
/ - ? : ( ) . , ‘ +

Example
     '020?Dome@&++;stic CT out;%going?20测试叙事测试叙事@@@@test'
Expected output is
    020?Dome++stic CT outgoing?20test


I am using the below query but it is replacing '+'. I don't want to replace this + because it a part of x character set.

select translate(REGEXP_REPLACE ('020?Dome@&++;stic CT out;%going?20测试叙事测试叙事@@@@test','[^' || CHR(32) ||'-' ||CHR (127) || ']', ''),'+=!“%&*<>;{@#_',' ') AS TEST from dual;
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Do you still need help with this? The SQL you've provided looks like Oracle, but the topics for the question are Statistical Packages and R, so it's confusing as to what you're wanting. Can you confirm you're using Oracle?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.