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
Post a Comment