string - Regex Replace Zero In Some Instances -
string - Regex Replace Zero In Some Instances -
i trying write regex statement replace 0 if next conditions true
example string:
0,10,9a,0,0,20,0ld,0
change zeros t0
the string above can in order , should business relationship possible alter in delims (,)
so string above should be:
t0,10,9a,t0,t0,20,t0ld,t0
this have far:
0(?=[a-z]|[1-9])|0
this get
t0,1t0,9a,t0,t0,2t0,t0ld,t0
the problem 10,20,30,40,50,60,70,80,90 beingness replaced should not.
you utilize negative lookbehind this.
(?<![1-9])0
or going off of current pattern.
(?<![1-9])0(?=[a-z1-9]?)
live demo
regex string replace
Comments
Post a Comment