Reputation: 1685
I'm setting up an AB test and I don't want certain pages, to be included in my AB test based on the query params in the URL.
I want to use regex to find two params in this URL:
If the param begins with &rooms
And if the second param begins with &offerRooms
https://www.website.com? search=true &to=21-12-2020 &from=14-01-2021 &rooms[0][adults]=2 &rooms[0][b]=0 &rooms[0][c]=0 &Id1=xxx &Id2=xxx &accId=abc &voucherCode=123 &boardType=HB &offerRooms[0][adults]=2 &offerRooms[0][b]=0 &offerRooms[0][c]=0 &dest=0
I have the following regex to find &rooms[0][adults]=2
:
(rooms)\W0\W\Wadults\W=[2-9]
But I'm not sure how to expand this, to also look for and match &offerRooms[0][adults]=2
Essentially, I want my regex to find both of this params in one regex lookup.
Any pointers would be helpful!
Thanks,
Upvotes: 0
Views: 188
Reputation: 4162
I'm not entirely sure of what it is you want to do.
This regex will find rooms[0][adults]=2
and offerRooms[0][adults]=2
.
Is that what you're looking for?
(rooms|offerRooms)\[0\]\[adults\]=[2-9]
If you only want the urls that contain both and rooms always comes before offerRooms it is straight forward.
rooms\[0\]\[adults\]=[2-9].*offerRooms\[0\]\[adults\]=[2-9]
If you only want the urls that contain both and rooms doesn't always come before offerRooms it is rather complicated and requires a lookahead. Here I look for rooms if followed by offerRooms OR offerRooms if followed by rooms.
(rooms\[0\]\[adults\]=[2-9](?=.*offerRooms\[0\]\[adults\]=[2-9])|offerRooms\[0\]\[adults\]=[2-9](?=.*rooms\[0\]\[adults\]=[2-9]))
Upvotes: 2