Matching a string after zeros at the beginning of a string is possible with a positive lookbehind like
(?<=^0*)[^0].*
The (?<=^0*)
lookbehind matches a location that is immediately preceeded with zero or more 0
chars at the start of string, and [^0].*
will match a char other than 0
and the rest of the string. See this regex demo.
In some regex flavors (like PCRE or Onigmo), you can use \K
match reset operator:
^0*\K.+
The ^0*
will match zero or more 0
chars at the start of the string and \K
will discard these matched chars from the match memory buffer. See this regex demo.
In the ICU regex flavor (R stringr
functions, Swift) or Java, you can use constrained-width lookbehind pattern. Say, you know there can be no more than 100 zeros on front. Then you can use
(?<=^0{0,100})[^0].*
The (?<=^0{0,100})
lookbehind matches a location that is immediately preceeded with zero to 100 zeros at the start of string, and [^0].*
will match a char other than 0
and the rest of the string. See this regex demo.