Improving regex to match better (and fix potential issues with greedy matches)