I have a text document where every line has an opening tag. I need to add a matching closing tag at the end of each line.

For example:

What I have:<exe>Example text between tags.

What I need:<exe>Example text between tags.</exe>

I am new to "Find & Replace" in Notepad++ but I've had some success formatting this document to my needs. Can someone provides some guidance/tips?

  • Does every line have an opening tag at the beginning? – Paul Aug 19 '15 at 0:20

This will put a matching closing tag at the end of every line. Go to search/replace and choose regex as the search mode.

Find what: ^<(.+)>(.+)$
Replace with: <\1>\2</\1>

The find what looks for the opening tag at the beginning of the line, and stores it in \1, and puts the rest of the line in \2

We then create the new line in the replace using \1 for the opening and closing tags, and \2 for the content in between.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.