java - Regex that matches only one occurrence -


i'm wanting replace occurrences of "=" "==" in string regex, there single occurrence of "=".

basically want transform:

where = b | c == d 

into

where == b | c == d 

what i'm struggling finding 1 occurrence. i've tried [^=]=[^=], matching characters on either side too.

you can try using lookarounds:

(?<!=)=(?!=) 

using example:

system.out.println("where = b | c == d".replaceall("(?<!=)=(?!=)", "==")); 
 == b | c == d 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -