Regular Expressions

RegEx examples primarily for notepad++

Published on Friday, 18 May 2018

This article currently covers notepad++ flavor or regular expressions.

Notepad++

notepad++ regex utilizes token \1, \2 to replace with matched terms under (.*).

Example table for find and replace,

Intent Find Replace
Replace -> D:\movies\superman.mkv with 'superman' (add quotes around) -> D:\\movies\\new\\(.*) '\1'
Replace the string starting with a space( ) and ending with : convert ^ (.*): convert$ and keep the matched part quoted around '\1'
Replace NSLog(@x) with printf(x) (NSLog\(@)(.*) (;) printf(\2
Remove line numbers from output of bash history cmd ^ 7.. null
Converting a batch script variables to Powershell variables ^([0-9][0-9][0-9] )(.*) \2
Remove number prefixes from bash history file ^\s*(\d|\d\d|\d\d\d)\s\s(\S) \2
Copying from github which contains line numbers as prefixes, then, removing line numbers ^([0-9][0-9][0-9] )(.*) \2
Given dependency repos name list, regular expression for clone repo (.*) clone_repo /builds/atiq/jv8/\1 \1 false

null above represents empty string.

Please note that replacement is not necessary if we only want to find.

npp regex refs

Notepad++ Trips and Tricks

Following SU - Flip or reverse line order in notepad++ we can reverse line orders for given text. Example use is in soln of the problem: 12. Integer to Roman

** Config Files ** config files can be found inside: $Env:APPDATA\Notepad++

configs for npp: custom backup: $PFilesX64DIR\npp\backup Theme: $Env:APPDATA\Notepad++\themes Themes settings Path: $Env:APPDATA\Notepad++

refs for themes