Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Eliminating leading 0 from an Alphanumeric string

8b676873-8d11-4a7e-b674-df55cc923325Apr 26 2017 — edited Apr 27 2017

Hi Team,

Can anyone please help me here.

I want to eliminate all leading '0' from an Aphlanumeric string but the condition is if string contains all zeros then it should leave one zero as output:

Ex:

I/p string: 0000123SUMIT

O/P: 123SUMIT

I/P: 000000

O/P: 0

I/P: 000120120SUMI

O/P: 120120SUMI

I/P: 000120-120~SUMI

O/P: 120120SUMI

I/P: null

O/P: null

I am using below expression but it is not fulfilling 2nd option(in Example)

select REGEXP_REPLACE('0000', '(*[[:punct:]|[:blank:]]|^0+)') from DUAL

Thanks in Advance.

Thanks ,

Sumit

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 25 2017
Added on Apr 26 2017
10 comments
1,355 views