RegEx to integrate Fogbugz with TeamCity

186 Views Asked by At

I'm trying to integrate Fogbugz issue tracking with TeamCity and I'm struggling to get the regex correct. We usually mark the case in the check in comment like "BugzID: 1234" but I'd like to get a regex that doesn't care about capitalization, or if the ":" is there. There can also be text before or after the bugzid.

I tried to use: \b(?(review|case|bug[zs]?(\s| )(id)?:?)s?(\s| )([#:; ]| )+)((([ ,:;#]|and)*)(?\d+))+

which I got from: help.fogcreek.com/7772/link-fogbugz-cases-to-changesetscommits-in-kiln

but it doesn't seem to be working correctly. The link it generates has "BugzID:" for the ID, which should be "1234".

Can any regex experts help?

Thanks!

1

There are 1 best solutions below

0
zx81 On

To match the ID only:

Option 1 (Perl, PHP, Ruby 2+)

(?i)bugzid:? \K\d+

Option 2 (Java, .NET)

(?i)(?<=bugzid:? )\d+

Option 3 (Other Engines)

/bugzid:? (\d+)/i

The ID is captured to Group 1. The way to set case-insensitivity in JS is shown, it will differ in some engines.