How to Swap text before and after a symbol in Notepad++

- Press Ctrl+H to open the Find and Replace window.
- Go to the Replace tab.
- Enable the Regular expression option.
Let's assume we have lines like text1|text2, and we want to swap the text before the | symbol and after it.
- In the Find field, enter the regular expression:
(.*)\|(.*)
- In the Replace with field, enter the expression:
\2|\1
- Click
Replace All
to replace all occurrences in the file.
Example
Before replacement:
example1|example2
exampleA|exampleB
After replacement:
example2|example1
exampleB|exampleA
Explanation of the regular expression
- (.*) — captures any text before the | symbol.
- \| — the delimiter symbol, in this case, |.
- (.*) — captures any text after the | symbol.
- \2|\1 — replaces the found text, placing the text after the symbol before it.
By using Notepad++ and regular expressions, you can change the order of parts of text separated by a specific symbol.