My file content is as below
abcd-12=jksjd-jkkj
xyzm-87=hjahf-tyewg-iuoiurew
zaqw-99=poiuy-12hd-jh-12-kjhk-4rt45
I want to replace the hypen with underscore sign after the '=' i.e on the R.H.S of the equation.
No of hypenated terms are variable in the lines, it can be 3 or 4 or 5
How to do this for the entire document. Left hand side should be intact.
My desired result is :
abcd-12=jksjd_jkkj
xyzm-87=hjahf_tyewg_iuoiurew
zaqw-99=poiuy_12hd_jh_12_kjhk_4rt45
This will replace any number of hyphens in a single pass:
(?:=|(?!^)\G).*?\K-
_
. matches newline
Explanation:
(?: # non capture group
= # equal sign
| # OR
(?!^) # negative lookahead, make sure we are not at the beginning of a line
\G # restart from last match position
) # end group
.*? # 0 or more any character but newline, not greedy
\K # forget all we have seen until this position
- # a hyphen
Screen capture (before):
Screen capture (after):