How to remove all leading zeroes in a string

前端 未结 10 1168
感情败类
感情败类 2020-12-02 07:16

If I have a string

00020300504
00000234892839
000239074

how can I get rid of the leading zeroes so that I will only have this



        
10条回答
  •  独厮守ぢ
    2020-12-02 07:51

    Regex was proposed already, but not correctly:

    
    

    output is then:

    4523423400023402340240
    

    Background on Regex: the ^ signals beginning of string and the + sign signals more or none of the preceding sign. Therefore, the regex ^0+ matches all zeroes at the beginning of a string.

提交回复
热议问题