I have 2 URL patterns that I want to target the same state:
/:client/:project/deliverables/resources_reports/:id/resources/:rsrc_id
/:client/:project/deliverables/issues_exports/:id/resources/:rsrc_id
I tried making a single state to manage this using regex to no avail. I'm not sure if the regexp is only applicable to the $stateParam keys in those URLs or not. Is there a way to make it something like this:
url: "/:client/:project/deliverables/(resources_reports|issues_exports)/:id/resources/:rsrc_id"`
Thank you in advance :)
I was missing one thing: it has to be set within a Url matcher's matching segment. The unexpected result is that you get another $stateParams property to utilize.
/:client/:project/deliverables/{d_type:resources_reports|issues_exports}/:id/resources/:rsrc_id
Related
I'm trying to target a set of URLs sharing the same template in Optimizely the https://chillisauce.com/hen/in-dublin/day
Specifically trying to target the hen/in- part and the /day part.
I've been testing this: /(hen)/in-.*/day[^/]+$
Although when testing the URL pattern in Optimizely it does not match.
Any ideas?
Thanks in advance
Charlie
Looks like Optimizely uses js regexes, so this should work:
\/(hen)\/in-.+\/day[^/]*$
See it in action here (allows you test on the fly modifications a little easier than optimizely's interface):
https://regex101.com/r/9Np4Oj/2
And you may want to consider following your later pattern ([^/]) here too.
\/(hen)\/in-[^/]+\/day[^/]*$
I am trying to create a regexp to fire a tag within Google Tag Manager on certain pages.
The issue I am having is that I do not want to fire this tag on URLs matching a querystring in them, since it is only a session identifier and I do not need the tag to fire on the pages that have a query string. These are basically duplicates and they do not need tracking in a 3rd party tracking program. I know how I could exclude them in GA, but I can't figure out how to do it for the third party tracking.
I'll detail the scenario below and what I have tried.
Example pages that come up in my URL report if I look in GA:
/page
/page/subpage?my-handsome-query-string&some-other-data
/page/subpage
/page/subpage/subsubpage
/page/?query-string-again
So what I want to do is to fire the tracking on pages that does NOT have the query string, and it is proving quite the issue.
If I put in ^/page.*[^\?] it just doesn't work. I guess I am completely using the negated character class all wrong? I can't get it working and would require some assistance on how to devise a better regexp.
Some other I tried were:
^/page/.* but this one only matched everything after /page/ but not /page.
I am not very good with regular expressions, so what I basically want to do is match /page, /page/subpage, /page/subpage/subpage etc, but not any URL that has a query string in it.
In GTM I can't create two rules that says "Include {{url path}} matching this" and "Exclude {{url path}} matching \?", so it all needs to be done within one regexp... And that totally got me at a loss.
Edit: Mike gave a good answer to solve my GTM part, but I am still interested in learning if it is possible to do above but with a single regex?
You can actually create two rules as you described.
In GTM, tags can have both Firing rules and Blocking rules. Blocking takes precedence. eg.
Firing rule:
{{url}} matches ^page/.*
Blocking rule:
{{url}} does not contain ?
Another option is to use a custom javascript macro.
It is in the form of a function(){ } which can detect a query string value in window.location.search and return boolean. Then have a firing rule {{your custom fn}} equals 1.
You can also create a macro which uses the URL macro type and Query component type.
The value is set to the query string without the leading ?. If the url was example.com?foo=bar this macro would contain foo=bar. Then simply add a firing rule {{query}} matches Regex ^$ or {{query}} does not contain something-that-will-never-be-in-the-url-to-avoid-regex
I have route:
app.get('/:id', routes.action);
It works fine, but I need skip robot.txt and other (humans ....)
I create regex (only chars or number):
/^[a-z]{0,10}$/
How I can route only ids, which match this regex?
Put the regex in parentheses like this:
app.get('/:id(^[a-z]{0,10}$)', routes.action);
If you want to avoid a route matching a static file that exists physically, simply put the static middleware before the call to the app.router.
Then the static file (such as robots.txt) will be delivered and these calls will not get through to your routing.
Problem solved ;-).
Internally, the strings that you give to the Express router are just converted into regexes anyway. If you look at the code, you can see that you can just pass a regex directly.
app.get(/^\/[a-z]{0,10}$/, routes.action);
The docs also have examples.
If you need it for multiple routes :
app.routes.get
is an array having all of the get routes.
You can change the regex object for the routes you need to change.
I am attempting to set up a goal funnel in Google Analytics. It is for an online quote request system that we want to track. Basically all the pages that contain the quote request form have unique dynamically generated urls that are similar. The form of the URL is:
/quoterequest/categoryone/categorytwo/productname/
I have regex that works for tracking that:
^/quoterequest/([A-Za-z0-9/-]+)?
Today we added a thank you page after the user submits the form. The URL is always the same for that:
/quoterequest/thanks/
I would like to modify the above regex so that it continues to match any of the Quote Request URLs, but NOT that thank you URL. I have been trying different variations, including t. he negative look ahead,but unfortunately I am not very experienced with regex and I think I've been doing it completely incorrectly. Can anyone give me some insight as to the correct method of doing this?
You can use:
^\/quoterequest\/(?!thanks\/?$)(?:([A-Za-z0-9\-]+)\/?)*$
See it
I'm using regex in lighttpd to rewrite URLs, but I can't write an expression that does what I want (which I thought was pretty basic, apparently not, I'm probably missing something).
Say I have this URL: /page/variable_to_pass/ OR /page/variable_to_pass/
I want to rewrite the URL to this: /page.php?var=variable_to_pass
I've already got rules like ^/login/(.*?)$ to handle specific pages, but I wanted to make one that can match any page without needing one expression per page.
I tried this: ^/([^.?]*) but it matches the whole /page/variable_to_pass/ instead of just page.
Any help is appreciated, thanks!
This regexp should do what you need
/([^\/]+)/(.+)
First match would be page name, and the second - variable value
Try:
/([^.?])+/([^.?])+/
That should give you two matches.