regex to strip leading zeros treated as string

后端 未结 6 1314
灰色年华
灰色年华 2020-12-30 04:28

I have numbers like this that need leading zero\'s removed.

Here is what I need:

00000004334300343 -> 4334300343

000

6条回答
  •  情深已故
    2020-12-30 05:06

    Another solution (might be more intuitive to read)

    str = str.replaceFirst("^0+", "");
    

    ^ - match the beginning of a line
    0+ - match the zero digit character one or more times

    A exhausting list of pattern you can find here Pattern.

提交回复
热议问题