Passing a regex in a GET parameter? - regex

I have a RESTful API endpoint with a Mongo backend. I allow users to filter their queries using GET parameters, e.g. to get analytics for the /about page on the site:
/page-analytics?filter_by=pagePath:/about
I would like to extend this to support regular expression filters, e.g. to get analytics for all pages below /about on the site:
/page-analytics?filter_by=pagePath:/about/.*
What is the safest way to do this? Should I enclose the regex inside enclosing markers, and should I get users to pass URL escaped variables?
My requirements are as follows: firstly, I would like to write backend code to check that we have a valid regex before passing it on to my database. Secondly, I don't want the regexes passed in by users to get messed up by URL escaping.
One example of a problem: I initially started by enclosing all my regexes in slashes, like /^about/.*$/, but that doesn't work well because my server removes trailing slashes from URLs.
If anyone has any tips, I'd be very grateful.

Related

Excluding a URL With Google Analytics Regex

I am tracking several urls on my website and I want to count only the ones beginning with /espace-debat
Examples :
/espace-debat/debat
/espace-debat/user/random-number
/espace-debat/debats/random-number
I am creating a goal on analytics to exclude all the others urls.
I am thinking about this Regex
^/(?espace-debat)
I don't know how to test it
Have you tried escaping your expression?
^\/(espace-debat)\/?

Google Analytics - Track Multiple Subdirectories (regex)

I am trying to create a view in Google Analytics to filter out the analytics from multiple subdirectories and all pages in them.
www.example.com/mysite
www.example.com/anothersite
www.example.com/lastsite
This is the regex I have written but when I run it, no results get returned ^/(mysite|anothersite|lastsite)?/*
Any ideas what I am doing wrong?
I was able to find a solution by first adding a trailing slash to the URLs (see: https://www.getelevar.com/how-to/fix-duplicate-url-google-analytics/) and then including a regex pattern of the request URI of ^/(mysite|anothersite|lastsite)/

ReGex to filter a list of URLs in a spreadsheet

Disclosure: me as I'm a newbie in these topics.
Is it possible to filter a number of URL rows in a spreadsheet using regex?
Quick story short: I have a list of URLs (.spreadsheet) and a list of regex functions which I'd like to use to filter and retrieve the URLs.
Long Version: I have a list of URLs of a website which are spread across several servers. And then, a list of regex expressions that each define the kind/format of URL that is hosted on each server. What I'm trying to do is to map the URLs of the site to the server they are hosted. *
That's all I have. Two lists. One of all URLs, one of the regex rules that define the server they belong. Do you suggest a quicker/easier way to accomplish this?
Thanks

Jmeter URL patterns to exclude under workbench - not excluding patterns that are giving there

Jmeter URL patterns to exclude under workbench - not excluding patterns that are giving there.
Can we give direct URL's. i have a list of URL that needs to be excluded from the recorded script.
Example:
'safebrowsing.google.com`
'safebrowsing-cache.google.com'
'self-repair.mozilla.org'
i'm giving these directly under patters to exclude. or do i need to give as a regular expression only.
Can someone provide more info whether to use regular expression or direct url can be provided under Requests Filtering in workbench
JMeter uses Perl5-style regular expressions for defining URL patterns to include/exclude so you can filter out all the requests to/from google and mozilla domains by adding the following regular expression to URL Patterns to Exclude input of the HTTP(S) Test Script Recorder:
^((?<google>|mozilla>).)*$
See Excluding Domains From The Load Test article for more details.
If you want any of the patterns to be excluded from recording in the scripts please follow the below pattern and add it in "URL Patterns to Exlcude" it must work.
1. For .html : .*\.html.*
2. For .gif : .*\.gif.* etc

How to set analytics goal for urls consisting of dynamically generated numbers in the url stub?

I have the url as shown below
http://www.somesite.com/icons/898989898998?download=1
I need to configure this url for the goal to find how many hits for this url. Kindly help me out in this.
I tried configuring /icons/\d*?download=1 with regular expression but it is not working.
you need to escape the ?
this matches 898989898998:
/icons/\d*\?download=1