I am trying to figure out if this regex will do what I am intending it to do. I am trying to filter all URIs that have “/in/” in the path.
example:
www.mysite.com/in/home.aspx
www.mysite.com/in/.../.../.../product.aspx
beasically anthing with /in/ after the .com will only be included but can have anything after it.
anything like www.mysite.com/cn/in/ will not be included.
I am using ^/in/* since I’m checking after the .com. I have never had much exposure until now any help will be greatly appreciated.
one thing after playing around with google analytics, there seems to be a big deifference with ^/in/* and ^/in/ the first one will show /industrys/ and any other directory that has /in… in it. while the ^/in/ will only show /in/
still if anyone is more of an expert in the matter I would love to hear some feedback.
out of curiousity, why not just static search for .com/in ?
Great question, that is because the .com could be .cn, .in, .co.uk
mysite.com/in/
mysite.co.uk/in/
mysite.cn/in/
the only thing that will be the same will be /in/
if(substr($_SERVER['PHP_SELF'],0,4) == "/in/") {
If the “URIs” have a scheme (start with “something://
”) then you could use parse_url()
to get the path (“/in/...
”) and examine that.
Of course, a regex could be written but without precise details (Can the URI start with a scheme, will it always, never? Can it be any URI, always a website, etc.?) they might not be particularly useful: especially if you’re not familiar with regex and don’t really know what it’s doing.