• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

remove leading zerros

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
sam2929
Asked:
sam2929
2 Solutions
 
slightwv (䄆 Netminder) Commented:
Try this:
select regexp_replace('420*0000001234','(.*\*)(0+)(.*)','\1\3') from dual;

Just replace my hard-coded string with your column name.
0
 
sdstuberCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now