Solved

remove leading zerros

Posted on 2014-04-17
2
159 Views
Last Modified: 2014-04-18
Hi,
i have data like below
420*0000001234
768*00000123


i want it to be
420*1234
768*123

how can i do it.

Thanks
0
Comment
Question by:sam2929
2 Comments
 
LVL 76

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 250 total points
ID: 40006908
Try this:
select regexp_replace('420*0000001234','(.*\*)(0+)(.*)','\1\3') from dual;

Just replace my hard-coded string with your column name.
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 250 total points
ID: 40006969
similar idea but simpler and more efficient without subexpressions and back refernces

just look for the asterisk and remove the 0s that follow


select regexp_replace('420*0000001234','\*0+','*') from dual;
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now