RegEx to remove chords from ChordPro files

Hey, quick post here to show you what I had to learn the hard way.

Problem: someone sends you a song in ChordPro format (or other formats that basically use ChordPro notation, like from OnSong or SongBook, etc.)  It has all the chords in it but you also or you only need the lyrics (without chords!)

Removing them can be tedious.

Solution: If your editor supports Regular Expressions (regex) for search and replace, you can do the following:

Search string:

^(.*)?\[.+?](.*)?$

Replace string:

\1\2

Caveats:

  • I only tested this with Notepad++
  • The syntax for the replace string might vary between editors.  This is for Notepad++, where each numbered place-holder in the replace string corresponds with one of the (.*) groupings
  • This removes one chord per line.  This is not a real problem.  If you do a “replace all” you replace one chord in all the lines and clicking that button several times will have done the trick fairly quickly.

Multiple files: While not tested, Notepad++’s “Find in Files” tab on the search/replace dialog should do the trick or equally the “Replace in all opened files” button on the Replace tab of the search/replace dialog.

Posted in Computers, Freeware.