Walid-Shouman
11/22/2016 - 12:42 PM

SOS regexes

SOS regexes

Those regexes were tested on Sublime text editor.
Use Regex101 to validate your regexes.

Decorate line content with #ifdef something and #endif something

find what \n(\w+)\n
replace with #ifdef something\n\1\n#endif something
Sample case:


abc

Remove any line starting with some string

find what everyline you dont want starts with me(.+\n)
replace with
Sample case:

An important line
everyline you dont want starts with me, woohoooooo
Another important line

Remove any line starting and ending with some string

find what everyline you dont want starts with me(.+)and ends with me\n
replace with
Sample case:

An important line
everyline you dont want starts with me, woohoooooo, and ends with me
Another important line

Replace start and end of line with a special format

find what -(([^^-])*)\n
replace with |$1||\n
Sample case:

- a line
- another line
- a third line

Good References

This article about regexes in sublime, could influence the future gists that get mature enough to be articles too :D