Improve regex to detect branches