Solved

remove leading zerros

Posted on 2014-04-17
2
165 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
[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

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 74

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
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.

691 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