I have tried everything possible and 2 hours trying to get this to work.
I'm using the search and replace option in Code (version 1) but just can't get the replace code working.
I want to add a semi colon in between some characters. I search like this:
)}[a-z]
..and that works fine.
and I've tried all of these, but not one keeps the [a-z] part, they all remove/replace it.
)};\1
)};*1
)};[a-z]
)};\1\2
)};$1
)};($1)
)};(\1)
)};[$1]
)};[\1]
I've set it to use the POSIX Basic option, but any option, setting will do. I just need it to simply insert a semicolon
This should work:
s/\)\}([a-z])/)};\1/g
In essence, we literally match a close parenthesis followed by a close brace. We then match a letter between a
and z
, but the parentheses around the [a-z]
make that a capture group that we can reference. We can then (and only then) use \1
in the replacement. Without a capture group, it doesn't know what \1
refers to. With one, it does.
Using it with sed
:
% echo 'hello)}world' | sed -Ee 's/\)\}([a-z])/)};\1/g'
hello)};world