MJ03
MJ03

Reputation: 31

How to select alphanumeric characters using regex

I am fairly new to regexp_substr in oracle. I want extract just alphanumeric character from the string below. I have used below query but it doesn't seems to be working as expected.

select 
    regexp_substr('Save up to 10% on National Brands and 20% on Quill Brand Laser Toner','[[:alnum:]]+') string 
from dual;

I want the output to be look like this

Save up to 10 on National Brands and 20 on Quill Brand Laser Toner

or

Saveupto10onNationalBrandsand20onQuillBrandLaserToner

Thanks in advance. :)

Upvotes: 3

Views: 7584

Answers (1)

benji
benji

Reputation: 606

I think you're looking for regexp_replace

select 
    regexp_replace('Save up to 10% on National Brands and 20% on Quill Brand Laser Toner',
                 '[^[:alnum:]]', '') string from dual;

SQL Fiddle

Upvotes: 3

Related Questions