Improve regex from @hasteur's commit