In sourcetree there's an option to use regex to make links.
I'm using #number and #number for both the task number and the pull request numbers.
'Usually' the pull request number is preceded by the string "pull request" or "Pull Request" or "Pull request".
At the moment I'm using: #(\d+) to match the task number but obviously this also matches the pull request number so I think that to accomplish what I want I need to only match #(\d+) if it is not following the words "pull request" how can I do this? or is there a better way to do what I'm trying to do?
Use a negative look behind:
(?<![pP]ull [rR]equest)#number
The syntax (?<!...) is a negative look behind. It asserts, but does not capture, that the characters preceding it do not match the pattern ....
There are three other flavours or look arounds:
(?<=...) a (positive) look behind(?=...) a (positive) look ahead(?!...) a negative look aheadWith similar, and hopefully obvious, effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With