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

< P> Example string:

  0,10,9 A, 0,0,20,0LD, 0  

All zeros to T0 < / Code>

  • 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 < / Li>
  • 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: < / P>

  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]?)  


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -