0

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!

user2097151
  • 131
  • 1
  • 6
  • Please give us a list of potential matches so we understand your input. Examples are better than words. – zx81 Jul 31 '14 at 00:20
  • Examples: "PUB - BugzID: 1234 - Fixed null reference", "INTERNAL - bugzid 2222 - added text box", "bugzid: 54321 - speed improvements to processing" – user2097151 Jul 31 '14 at 00:42
  • Working on it. You just want to match the ID? – zx81 Jul 31 '14 at 01:05

1 Answers1

0

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.

zx81
  • 41,100
  • 9
  • 89
  • 105