RegEx to integrate Fogbugz with TeamCity - regex

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!

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.

Related

Google Analytics Regex - Matching Specific Words, but Not Others

I don't usually use Regex. I'm working on Google Analytics Goals and I want to create a step in the funnel that will match URLs containing /resource/ and the word ebook or report, but do not include thank or thanks.
It would match:
/resource/example-ebook-request
/resource/research-report-2018/
It would not match:
/resource/example-ebook-request/thank-you/
/resource/research-report-2018/thanks/
/some-other-ebook-no-resource-subfolder/
I'm having a hard time getting the combination of this correct in a way that will work for Google Analytics since it doesn't support look behind. Any suggestions?
Try Regex: \/resource\/[^\/]*(?:ebook|report)[^\/]*\/?$
Demo

Selenium IDE: Verifying a dynamic pattern in a website using RegExp

I am trying to verify the presence of the dynamic string "6:20 AM – 6:46 AM" in this website in selenium IDE using Regular Expressions but it doesn't work. I can't use XPath since the numbers keep changing and I am looking for only certain numbers. If I use XPath, it will match the string no matter what the numbers are. What is wrong with the following?
Command: verifyTextPresent
Target: regexp:[6]\:[0-9]{2} [AP]M \– [6]\:[0-9]{2} [AP]M
This question seems too simple but not in real, please check your solution and see if it really works on the aforementioned website. Please note that my question is not only about RegExp! I'm asking about using RegExp in Selenium IDE.
Does your string have anything before it - Perhaps escaping it with backspaces queries
\s
might be advisable?
Sunrise Today: 6:19 AM
Sunset Today: 8:38 PM
Notice how there is a gap before the 6 begins.
So a potential output code here would be
\s[0-9]+:[0-9]+\ [AP]M
\s[0-9]+:[0-9]+\ [AP]M
The fellow above restricts it to 1 or 2 using {1,2}, and technically this is more accurate, but mine is more shorthand, and on a timing website where you will only get 1 or 2, my method would work (Regex '+' is 1 or more instances).

Filter by regex example

Could anyone provide an example of a regex filter for the Google Chrome Developer toolbar?
I especially need exclusion. I've tried many regexes, but somehow they don't seem to work:
It turned out that Google Chrome actually didn't support this until early 2015, see Google Code issue. With newer versions it works great, for example excluding everything that contains banners:
/^(?!.*?banners)/
It's possible -- at least in Chrome 58 Dev. You just need to wrap your regex with forward-slashes: /my-regex-string/
For example, this is one I'm currently using: /^(.(?!fallback font))+$/
It successfully filters out any messages that contain the substring "fallback font".
EDIT
Something else to note is that if you want to use the ^ (caret) symbol to search from the start of the log message, you have to first match the "fileName.js?someUrlParam:lineNumber " part of the string.
That is to say, the regex is matching against not just the log message, but also the stack-entry for the line which made the log.
So this is the regex I use to match all log messages where the actual message starts with "Dog":
/^.+?:[0-9]+ Dog/
The negative or exclusion case is much easier to write and think about when using the DevTool's native syntax. To provide the exclusion logic you need, simply use this:
-/app/ -/some\sother\sregex/
The "-" prior to the regex makes the result negative.
Your expression should not contain the forward slashes and /s, these are not needed for crafting a filter.
I believe your regex should finally read:
!(appl)
Depending on what exactly you want to filter.
The regex above will filter out all lines without the string "appl" in them.
edit: apparently exclusion is not supported?

Regex for Google goal tracking

I am trying to create the regex to track goal conversions on my site (with a dynamic url).
URL: sitename.com/username/year (or all)
So this would be /johnsmith/2014 or /johnsmith/all
As the usernames and years can vary, I put the regex as /[A-Za-z0-9-_.]{2,16}/all|[0-9]{4}/
This isn't working at all. Could someone please help me
how about this regex
/([\w.]+)\/((?:\d+|all))/
Test string
sitename.com/johe8.nsmith/2014
sitename.com/johnsmith/all
Result
MATCH 1
[13-25] johe8.nsmith
[26-30] 2014
MATCH 2
[44-53] johnsmith
[54-57] all
demo here
if you have restrictions as mentioned in the questions, you may perhaps use the regex below
/([\w.]{2,16})\/((?:\d{4}|all))/
demo here

Why won't this regexp work in google spreadsheets?

I'm trying to extract from a url using a regexp in google spreadsheets. However the spreadsheet returns #VALUE! with the following error: Invalid regular expression: invalid perl operator: (?<
Here is the regexp I'm using: (?<=raid_boss=)[a-zA-Z0-9_]+
A sample url will contain a variable in it that says raid_boss=name. This regexp should extract name. It works in my testing program, but not in google spreadsheet.
Here is the exact contents of the cell in google spreadsheets: =REGEXEXTRACT( B1 ; "/(?<=raid_boss=)[-a-zA-{}-9_]+" )
Any insight or help would be much appreciated, thank you!
Sounds like whatever regular-expression engine Google Docs is using doesn't support lookbehind assertions. They are a relatively rare feature.
But if you use captures, REGEXEXTRACT will return the captured text, so you can do it that way:
=REGEXEXTRACT( B1 ; "raid_boss=([a-zA-Z0-9_]+)" )
Javascript is not the issue - Google Sheets uses RE2 which lacks lookbehind
along with other useful things.
You could use:
regexextract(B1, ".*raid_boss=(.*)")
or else native sheet functions like FIND, SUBSTITUTE if that isn't working
Finding a good regex testing tool is tricky - for example you can make something that works in http://rubular.com/ but fails in GSheets. You need to make sure your tool supports the RE2 flavour eg: https://regoio.herokuapp.com/