I need to add - in between of regex match in text file. I tried this but no luck!
-L\d{1,2} # this match all I need
Sa-L1
Sa-L23
Desire output:
Sa-L-1
Sa-L-23
There are -L in the lines, but I want to change -L with digits.
I need to add - in between of regex match in text file. I tried this but no luck!
-L\d{1,2} # this match all I need
Sa-L1
Sa-L23
Desire output:
Sa-L-1
Sa-L-23
There are -L in the lines, but I want to change -L with digits.
Use
(-L)(\d)
Replace with $1-$2
or \1-\2
.
See regex proof.
EXPLANATION
--------------------------------------------------------------------------------
( group and capture to \1:
--------------------------------------------------------------------------------
-L '-L'
--------------------------------------------------------------------------------
) end of \1
--------------------------------------------------------------------------------
( group and capture to \2:
--------------------------------------------------------------------------------
\d digits (0-9)
--------------------------------------------------------------------------------
) end of \2