string - Regex Replace Zero In Some Instances -
I am trying to write a regex statement that will change all 0 if the following conditions are true Example string: 0,10,9 A, 0,0,20,0LD, 0 All zeros to T0 If there is 1-9 in front of 0, then it does not change if the first letter or last letter is 0, then convert it to a T If zero is the letter after zero, then change it as T0 in the same letter as before The above string can be in any order and account for possible changes in it should be Delims (,) then the above string should be: T0, 10, 9, A, T, T, 20, TLL, T This is what I've done so far: 0 (? = [AZ] | [1- 9]). 0 What this is what I get T0,1T0,9A, T0, T0,2T0, T0LD, T0 The problem is 10,20,30, 40,50,60,70,80,90 are being replaced, they do not want You can use negative lookbench to do this. (? Or moving away from your current pattern. (? & Lt;! [1-9]) 0 (? = [A-Z1-9]?)