I think you could solve this without regex too. Can you try using the "Refactor Hierarchy" command, then typing "second.first" on the first prompt, then "first.second" on the second prompt? It will show you how it's going to rename the notes first, so you can confirm if this is what you want.