Solved

Oracle SQL - Removing Alphanumeric Characters from Strings

Posted on 2013-11-19
2
1,261 Views
Last Modified: 2013-11-19
Hi,

I'm trying to search in my name field for the records with no alphanumeric values.
I want to find the records with only null value or only special characters such as . , ? ! * % #.

For example,

ID       Name
----     ----------
1         James Brown??..
2
3         ...
4        >,*..??
5        1/James Brown***

Then, I want my code to return only ID 2,3,4 and not 1,5.
Also, I need to put this check in a case statement, rather than in a where clause.

Can you please help me how I can write this check using regexp_like or regexp_replace?

Thank you!
0
Comment
Question by:iamnamja
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 300 total points
ID: 39659345
Try this:

drop table tab1 purge;
create table tab1 ( id number, col1 varchar2(100));

insert into tab1 values(1,'James Brown??..');
insert into tab1 values(2, null);
insert into tab1 values(3,'...');
insert into tab1 values(4,'>,*..??');
insert into tab1 values(5,'1/James Brown***');
commit;

select id from tab1 where not regexp_like(col1,'[A-Za-z0-9]') or col1 is null;

Open in new window

0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 200 total points
ID: 39659359
select id from your_table where regexp_like(name,'^[.,?!*%#]+$') or name is null;

simply add whatever characters you want into the [] list
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question