cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Regex to capture URL

tarun_agastya2
Inactive

Hi,

I would like to create regex based on URL.Below is the URL format that should capture.

https://www.abc.com/smartphones/samsung-galaxy-s9-plus/?usrPrc=.edge-monthly-price#sku=sku1234 https://www.abc.com/smartphones/motorola-g7/?usrPrc=.edge-monthly-price#sku=sku2222 https://www.abc.com/smartphones/iphone-7/?usrPrc=.edge-monthly-price#sku=sku2222

I have tried this one but it was not working as expected [https://www.abc.com/smartphones/](.*)?usrPrc=.edge-monthly-price#sku=(.*) but in the middle because of .* it was taking someother urls also. for all the URL's until smartphone it was same and from ?it will be same until sku. can someone help me in fixing this.

Thanks,

Tarun

4 REPLIES 4

Babar_Qayyum
Leader

Hello Tarun,

I am really not good in the regex, therefore, if you found that the below regex is also not working for you then we will have to wait for someone to help us out.

.*(smartphones)?usrPrc=.+

Regards,

Babar

janusz_dabrowsk
Dynatrace Pro
Dynatrace Pro

Hello, but what would you like to capture actually ?

The_AM
Dynatrace Pro
Dynatrace Pro

Hi Tarun,

I believe I could help you here.

First off, I'd suggest using the URI pattern value business transaction measure for your filter/result/split. On your measure properties - remember to select Custom URI and check the box for including the query string in the pattern.

You need to escape regexp characters like "?". Also, keep in mind that dot-start (.*) is an expensive regular expression and better to avoid it.

This regexp will provide a group match on the SKU. Is that what you wanted?

.\*\/smartphones\/.\*/?\?usrPrc=\.edge-monthly-price\#sku=([a-zA-Z0-9]*)

Regards,

Andrew M


Regards,
Andrew M.

kin_wai_koo
Inactive

Hi Tarun,

Try this:

.*/smartphones/([^/]*).*#sku=(.*)