Monday, July 21, 2014

Elimination of Special Characters In the String.

I have come across a situation where I was supposed to eliminate all the special characters
( %$#(@!&)^*_+ ) in the string.

And, here is the way I just sorted everything back using REGEXP_REPLACE function.

Syntax : REGEXP_REPLACE( <Your_String> ,'[^[:alnum:]'' '']', NULL)

You can eliminate the special characters as shown in the below example else you can replace the special characters.The example1 shows to eliminate the special characters and example2 shows to replace the special characters.

Example1:
SELECT REGEXP_REPLACE('@$$My%%Blog&&*()','[^[:alnum:]'' '']', NULL) FROM dual;

O/P :
Myblog

Using TRANSLATE function

Example2:
SELECT translate('@$$My%%Blog&&*()', '[0-9]#@%%$&&!_','[0-9]') FROM dual;

O/P :
MyBlog*()

Related Posts : 

To find the Nth Record from Comma Separated String.

Challa.

No comments:

Post a Comment