Last active
September 27, 2024 21:12
-
-
Save ramons03/6152802 to your computer and use it in GitHub Desktop.
Notepad++ Advanced search and replace. Null, Enter char, Tab, Regular Expressions, Etc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Open the find/replace dialog. | |
At the bottom will be some Search mode options. Select "Extended (\n \r \t \0 \x...)" | |
In either the Find what or the Replace with field entries, you can use the following escapes: | |
\n new line (LF) | |
\r carriage return (CR) | |
\t tab character | |
\0 null character | |
\xddd special character with code ddd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- [!] finds the exclamation character. | |
- .* selects the rest of the line. | |
- (\+.*)(Item) \+ finds the + character. | .* selects the text after the + up until the word "Item" | Item finds the string "Item" | () allow us to access whatever is inside the parentheses. The first set of parentheses may be accessed with \1 and the second set with \2. | |
- \1\r\n\2 will take + and whatever text comes after it, will then add a new line, and place the string "Item" on the new line. | |
- A-Z finds all letters of the alphabet in upper case. | |
- a-z finds all lower case letters. | |
- A-Za-z will find all alphabetic characters. | |
- [^...] is the inverse. So, if we put these three together: [^A-Za-z] finds any character except an alphabetic character. | |
- Notice that only one of the [^A-Za-z] is in parentheses (). This is recalled by \1 in the Replace with field. The characters outside of the parentheses are discarded. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Enable the "Extended" search selector, and then in the "Find" box, add an "\r\n" to the right of your semicolon, e.g. ";\r\n". That will find only semicolons that are at the end of lines.
Note that if you are doing a "Replace" operation, you'll also need to add the "\r\n" to the end of the replace-text, otherwise the newline's will be removed, making it one long continuous line.