• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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