regex include main page visits from one keyword - regex

I got a lot of visits to my site main page from different keywords. Examples of format might be as following:
/?keyword= train hard
/
/?keyword=
etc., etc.
To be able to sum up all visits to my main page despite from the keyword, I wanted to use a Regex like ^/$. However, that didn't work out. What RegEx should I apply to get the proper result?
What RegEx should I apply to see other sections of my website in a similar way? E.g.
/booking?keyword= or /section?keyword=any ?
Thanks in advance!

For main page you can try: ^\/(?:\?keyword=.*)?$
Look here for example: https://regex101.com/r/5uCFun/2
For other pages similarly: ^\/booking(?:\?keyword=.*)?$
Example here: https://regex101.com/r/1dAaHL/2

Related

Regular expression to get specific pages out of a list of landing pages in Google Analytics

In Google Analytics, I need to select landing pages for each hotel my client operates. Hotel pages are identified by the string /hotels-in-XYZ/.
I need to exclude all other pages
I need to exclude sub pages like /hotels-in-XYZ/offer-page/ too
Sample list of hotels:
/XXX-one/login/
/hotels-in-ranthambhore/
/hotels-in-jaipur-resort/
/hotels-in-morocco-marrakech/
/about-us/
/hotels-in-mumbai/
/hotels-in-bengaluru/
/hotels-in-agra-resort/special-offers/extended-stay-offer/
/hotels-in-shimla/amp/
/hotels-in-udaipur-resort/amp/
I'm not that familiar with regex and I've been googling to find a solution. The closest I have is .*?\/hotels(.*)\/.* but it does not exclude page like /hotels-in-shimla/amp/
Your help would be appreciated. Let me know if I need to post any additional information to explain the question better.
Does ^\/hotels-in-[\w\-]+\/$ work for you?
I tested this at https://regex101.com/r/9c2IRC/1/

Regex specific question and search function on my website dealing with broken links

I've been trying to figure out my regex pattern but it doesn't seem to be working for me.
Here's what i'm trying to do:
I have broken links on my website if someone accidentally gets to a page like so:
https://example.com/catalogsearch/result/?q=
or
https://example.com/catalogsearch/result/
So i'm redirecting them back to my homepage. The problem is now the search is just sending everything back to the homepage. So i'm assuming if there is something after the equals it needs to continue the search.. obviously
https://example.com/catalogsearch/result/?q=person
but currently i can't figure this out..
Here is my regex that i've been messing with for quite sometime now... still seems to be wrong or something else is wrong with my search.
"^/catalogsearch/result((/)|(/\\?)|(/\\?[a-z])|(/\\?[a-z]=))?$"
Please forgive me i'm horrible with regex.
After a lot of discussion, it is concluded that the routes.yaml will consider the url path as a valid route but not the query string part. Hence out of the two examples in the post, you can use
"/catalogsearch/result": { to: "https://example.com/", prefix: false }
and for other one please change it in nginx config to redirect to homepage or if its not possible then check with magento support on how to incorporate the query string part in routes.yaml file.

Regex to replace spam links in Wordpress

I am dealing with old hacked sites in Wordpress where there are injection spam links on images.
I have access to the database and would like to remove links that look like this:
<a style="text-decoration:none" href="/ansaid-retail-cost">.</a>
Now text varies inside the <href> it might be for cialas or any product, but the rest doesn't vary. I want to remove the entire LINK, so the result is a single space.
I don't know regex, so I would appreciate the help. I've tried online generators but they don't seem to be working.

Analytics Goal Funnel Regex doesn't recognize "example.html?p=2"

I have my goal funnel set up and this is the regex for one of the stages: ^/shop/(.*)
This will match pages such as /shop/collections/art.html but when I look at the goal funnel, it says people are dropping out by going to pages like /shop/collections/art.html?p=2. Notice the ?p=2 is the only difference here.
I tried to do it as ^/shop/((.|\?)*) but I'm not sure that's fixing it.
How do I fix this?

How to define parent and subpages in Trac?

I know the Confluence wiki pretty well, and I like much the natural hierarchy of pages you get there. I have to use now a Trac wiki (which is not that bad, same root as MoinMoin), and am searching the feature here. What I want to reach:
Edit the page "MyPage" and enter there the link to a page you want to be a subpage, eg. MySubPage.
The link should be similar to /MySubPage or [/MySubPage]. The character "/" denotes that the resulting page should be a subpage of the current one.
Follow the link, create the new page with some content.
You should now see, that "MySubPage" is a subpage of "MyPage". You could reach the subpage from anywhere by the link MyPage/MySubPage.
The MoinMoin wiki has that feature at least from version 1.5.x, and I have used that regularily. Is there something similar in Trac? Do I have to install then a plugin?
Thank you a lot
Markus
Well, not the best thing to answer the own question, but just something I found out.
* SubpageFirst
* SubpageSecond
* SubpageThird
* SubpageFourth
leads to (of course) four pages, but when you have a look at them in Title Index, you will see:
* Subpage
* First
* Second
* Third
* Fourth
Not what I have searched for, but comes near.
The only way I have found to do something like this is to specify the full path to the page. For your example this would be [[MyPage/MySubPage]]. You then get a hierarchy in TitleIndex, but it leaves much to be desired in terms of presenting a Parent/Child relationship.
I think, as retracile mentioned, that MyPage/MySubPage does not create a true hierarchy, but rather just a page containing a forward slash in the name, and in TitleIndex the pages are presented such that they appear to be in a hierarchy (but often do not display the way you would like; as I mentioned it leaves much to be desired).
Parent-child wiki pages aren't directly modeled in Trac. Essentially, "/" is allowed as part of a wiki page name.
You should be able to create a macro that does something like what you want; essentially:
[[sub(MySubPage)]]