Issue Navigation - Substring using regex - regex

Intellij IDEA 12
I wanted to add a new issue navigation link (Settings -> Version Control -> Issue Navigation) for Bitbucket issues (has pattern: https://bitbucket.org/user/repo-name/issue/123).
I want issue ID would be #n (for instance #3, #123 etc).
How can I input issue ID as a regular expression? #\d+ ?
Is it possible to make substring using regex expression because it shouldn't be a hash in the Bitbuckt issue URL?

Try the following:
#(\d+) -- https://bitbucket.org/user/repo-name/issue/$1

Related

Can I use regex pattern matching for a CSS selector in Appium mobile automation?

I am trying to find a set of iOS UI elements in my automation script.
The framework is written in JS and utilizes Appium & WebdriverIO.
I was able to determine that the correct regex pattern I am searching for is this:
[-+][\d]{1,3} which finds a string that starts with either +/- and is of 3 numerical digits in length.
The current implementation I use is:
var strings = await $$("XCUIElementTypeStaticText[name*='[\d]{3}]']");
but I do not believe that is correct because when I print out the array length in console, it does not match to what is displayed in the iOS client UI.
Is it possible to use regex pattern matching when trying to find mobile application UI elements via CSS selector?
It is not possible to use regex as part of the css expression. If possible please try adding testIdentifiers to those elements or use XCUITest predicates as suggested here

Chrome dev tools: any way to exclude requests whose URL matches a regex?

Unfortunately in the last versions of Chrome the negative network filter doesn't work anymore. I used this filter in order to exclude each http call containing a particular string. I asked a solution in Chrome dev tool forum but at the moment nobody answered.
So I would like to know if there is a way to resolve this problem (and exclude for example each call containing the string 'loadMess') with regex syntax.
Update (2018):
This is an update to my old answer to clarify that both bugs have been fixed for some time now.
Negate or exclude filtering is working as expected now. That means you can filter request paths with my.com/path (show requests matching this), or -my.com/path (show requests not matching this).
The regex solution also works after my PR fix made it in production. That means you can also filter with /my.com.path/ and /^((?!my.com/path).)*$/, which will achieve the same result.
I have left the old answer here for reference, and it also explains the negative lookup solution.
The pre-defined negative filters do work, but it doesn't currently allow you to do NOT filters on the names in Chrome stable, only CONTAINS. This is a bug that has been fixed in Chrome Canary.
Once the change has been pushed to Chrome stable, you should be able to do loadMess to filter only for that name, and -loadMess to filter out that name and leave the rest, as it was previously.
Workaround: Regex for matching a string not containing a string
^((?!YOUR_STRING).)*$
Example:
^((?!loadMess).)*$
Explanation:
^ - Start of string
(?!loadMess) - Negative lookahead (at this cursor, do not match the next bit, without capturing)
. - Match any character (except line breaks)
()* - 0 or more of the preceeding group
$ - End of string
Update (2016):
I discovered that there is actually a bug with how DevTools deals with Regex in the Network panel. This means the workaround above doesn't work, despite it being valid.
The Network panel filters on Name and Path (as discovered from the source code), but it does two tests that are OR'ed. In the case above, if you have loadMess in the Name, but not in the Path (e.g. not the domain or directory), it's going to match on either. To clarify, true || false === true, which means it will only filter out loadMess if it's found in both the Name and Path.
I have created an issue in Chromium and have subsequently pushed a fix to be reviewed. This has subsequently been merged.
This is answered here - for latest Chrome 58.0.3029.110 (Official Build) (64-bit)
https://stackoverflow.com/a/27770139/4772631
E.g.: If I want to exclude all gifs then just type -gif
Negative lookahead is recommended everywhere, but it does not work.
Instead, "-myregex" does work for me. Like this: -/(Violation|HMR)/.
Chrome broswer dev tools support regrex filter not very well.
When I want to hide some requests, it does not work as showed above. But you can use -hide1 -hide2 to hide the request you want.
Just leave a space between the conditions, and this does not match the regrex, I guess it may use string match other than regrex in principle
Filtering multiple different urls
You can negate symbol for filtering the network call.
Eg: -lab.com would filter lab.com urls.
But for filtering multiple urls you can use the | symbol in the regex
Eg: -/lab.com|mini.com/ This will filter lab.com and mini.com as well you can use it to filter many different websites or urls.
You can use "Invert" option to exclude the APIs matching a string in the Filter text box.
On latest chrome version (62) you have to use :
-mime-type:image/gif

Matching URL containing one word AND another word using Regex

I am trying to write a regular expression to be used in a Google Analytics goal that will match URLs containing
?package=whatever
and also
/success
The user will first visit a page like
www.website.com/become-client/?package=greatpackage
and if they purchase they will be lead to this page
www.website.com/become-client/?package=greatpackage/success
So based on this I could use the following regex
\?package\=greatpackage/success
This should match the correct destination and I would be able to use this in the goal settings in Analytics to create a goal for purchases of the greatpackage package.
But sometimes the website will use other parameters in addition to ?package. Like ?type, ?media and so on.
?type=business
Resulting in URLs like this
www.website.com/become-client/?package=greatpackage?type=business
and if they purchase they will be lead to this page
www.website.com/become-client/?package=greatpackage?type=business/success
Now the /success part is moved away from the ?package part. My questions is how do I write a regex that will still match this URL no matter what other parameters there may be in between the parts?
---update----
#jonarz proposed the following and it works like a charm.
\?package\=greatpackage(.*?)/success
But what if there are two products with nearly the same name. For example greatpackage and greatpackageULTRA. The code above will select both. If changing the product names is impossible, how can I then select only one of them?
The regex that would solve the problem introduced in the edit, would be:
\?package\=greatpackage((\?|\/)(.*?))?\/success(\/|\b)
Here is a test: https://regex101.com/r/jS4cH5/1 and it seems to suit your needs.
If you want to match an url like this one :
www.website.com/become-client/?package=greatpackage?type=business?other=nada/success
With a group to extract your package type :
.*\?package=([^\/?]+).*\/success
Without group (just matching the url if it's containing package=greatpackage and success)
.*\?package=greatpackage.*\/success
Without group and matching for any package type :
.*\?package=[^\/?]+.*\/success
You just need to add .* to match any char (except new lines). The [^/?]* part is there to be sure your package type isn't empty (ie : the first char isn't a / nor ?).

RegEx to integrate Fogbugz with TeamCity

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.

Using regexp in Google Analytics Goal Funnel steps

I have a goal that can be reached from two pages on my website, for example, /page1 and /page2. I've made a regular expression for the first 'Required step' of the visualization funnel:
^/(page1|page2)$
If i apply it as a filter in the Top Content report - it works fine. But there's nothing registered in the conversion funnel. I actually couldn't find any information about funnel steps - is it even possible to use regexp there just like it's done in the Goal page URL?
I've just been bitten by this. The URLs in the funnel steps are the same as the Goal Destination URL:
https://support.google.com/analytics/answer/1116091?hl=en#matchTypes states
There are three diferent match types that define how Google Analytics identifies a URL for either a goal or a funnel. The match type that you select for your goal URL also applies to the URLs in the funnel, if you create one.
So you can only have regex matches in your funnel steps, if you've chosen Regular Express in the Destination dropdown.
I had the same problem as you. I'd chosen "Equal to" in the dropdown for the destination URL but was using "Begins with" style matches in my funnel steps and therefore getting 0 entries showing in my funnel visualisation.
The following article states that the goal steps should be defined as regex as well.
http://www.analyticsmarket.com/blog/create-google-analytics-goals
"Each step should be defined as a regular expression as well."
(almost at the very bottom of the page)
Hope it helps
Try removing the first character: ^.