Notepad ++ - how to add a character to the beginning of a line

I am trying to add parentheses to the beginning and end of a line in Notepad ++. Using sed, I would do:

sed -i 's/^/(/' filename sed -i 's/$/)/' filename 

and do it, but I have to use Notepad ++ on Windows. I went to find and replace, select regular expressions and tried to replace "^" with "(", but I got a "zero length" and does not add a character (same with replacing "$" with ")")

What am I doing wrong?

+8
regex notepad ++ sed
source share
2 answers

Sorry, I found the answer right after I posted the question. In case anyone is interested, in Notepad ++ you need to escape parentheses, while you don't need sed.

In Notepad ++, in the "Replace with" section, select:

  \( 

and it will work.

+2
source share

In the search field, enter ^(.*)$ And in the replacement field \(\1\) . It worked fine for me.

+13
source share

All Articles