Notepad++ had been one of my favorite tool for writing scripts, editing
and formatting. Regular expression support that has makes it very
powerful tool in analyzing logs, by searching/replacing patters.
1.String that contains a pattern
abc.* matches with abc, abcd, abc pqr,See the highlighted text below.
2. Line starting with a string
^abc.* matches with the lines that starts with abc.* . See the highlighted test below.
3. Lines that ends with a particular pattern
abcd$ matches with all the lines that ends with abcd as shown below.
4. Lines that starts and ends with a particular pattern
(a) ^abcd$ matches with all the lines that has only abcd in it.
(b) ^a.*g$ matches with all the line that starts with a and ends with g.
5. Patters with a character that can occur more than once in a pattern
a+ matches with all the occurrence of a as shown below.
6. Lines that doesn't have a pattern
Here is an example of searching for a line that doesn't have apostrophe ( ' ) in it.
^(?!.*').*$
7. (Below is the example that shows the search of lines with apostrophe
^.*'.*$
)
8.
^(?!.*(hello)).*$ This selects lines that doesn't have "hello" in it.
9. Replacing all comments starting with // with /* */
Find what:
^\/\/(.*)$
Replace with:
/*$1*/
10. Swapping two sides of =
Find what:
^(.*)=(.*)$
Replace with:
$2=$1