RegEx help

Hi all, this one should be easy for you scripters out there.

I want to create some Web Proxy rules where I want to match “example.com” and “*.example.com” (eg. www.example.com, whatever.example.com, www1.www2.example.com, etc) but not www.thisisanexample.com.

I tried this:

^(.*\.)?example.com$

.. which gave me the desired result when tested here http://regexpal.com/

but it didn’t work in RouterOS.

Any ideas?

[revised 2021-09-24 for 6.47.10]

It’s more simple than you think:

some example:
block any *.doubleclick.net (Advertising provider)

/ip proxy access
add action=deny dst-host=":(^|\\.)doubleclick\\.net" redirect-to="192.168.1.1/mikrotik_logo.png"

Why redirect-to=“192.168.1.1/mikrotik_logo.png”?
If you broken the contents of some sites with blocking, the webpage are corrupt, in this way a MikroTik logo are displayed instead of page error… :astonished:
You can use any type of image, but must be one image for working well…

block any domain where facebook is one part of name

/ip proxy access
add action=deny dst-host=":*\\.facebook\\.*" redirect-to="this.is.my.site.com/you_are_fired.http"

(for blocking some sites also on https another way is needed…)

block third level domain *.ads.thisexample.org but not the main domain

/ip proxy access
add action=deny dst-host=":(^|\\.)ads\\.thisexample\\.org" redirect-to="192.168.1.1/mikrotik_logo.png"

Ciao Rex,

thanks for the comprehensive reply, but what I’m looking for is to block:

*.doubleclick.net
doubleclick.net

The rules you specified will only block http://*.doubleclick.net, but will allow http://doubleclick.net.

I could use *doubleclick.net, but that will also block http://www.thisisnotdoubleclick.net, which I do not want.

I want to:
Block http://.doubleclick.net
Block http://doubleclick.net
Allow http://
.thisisnotdoubleclick.net
Allow http://thisisnotdoubleclick.net

Use first example: post fixed

Buon Lavoro!

Grande!!

That’s exactly what I was looking for… looks like I had a typo and added an extra : in ROS… :open_mouth:

Buona domenica e grazie!

Grazie, anche a te!

Ciao.

can you please write the correct line. i get error in terminal when i write this.
expected end of command (line 1 column 28)

I fixed my first post.

Is the karma collection some kind of contest?

Sent from Android by Tapatalk.

No, we are not payed for giving support, is only a little satisfaction… nothing else. :slight_smile:
Like a little cherry for each problem solved. :sunglasses:

On reality, give support to other users, is giving me some new ideas…
Gain on both parts!

I know that. Just was provocated by repeating readings of karma requests…

Sent from Android by Tapatalk.

One example: this request not are on my signature, :astonished:
If you see all my posts, i make the “suggestion” when I put some code or very useful informations. :laughing:

On some user the request are permanently written on the signature… :laughing:

Just FYI… I for one, and I’d guess jarda and others too… find “in post” prompts more annoying than signature prompts.

Why? Because “in post” prompt requires an extra effort from you, since you actually had to write it, as opposed to it being automatically added. This in turn makes it seem like you’re “begging” for it, like it’s really important to you, as if it’s a contest or something, and it’s the “begging” that’s annoying. Karma should be a “BTW thing”, not “in-your-face thing”.

Just FYI :confused:
“BTW what?” :confused:
Slang to English?

I write on the signature only the essential …

I find more annoying: the acronyms or slang abbreviations not understandable!
This forum is read all over the world,
one thing is to use the English language,
one thing is for “slang” abbreviations. Are not understandable to non-english users.
Obviously some acronyms as a raid dhcp “etc.” MUST be used …

Not English slang - internet slang. See UrbanDictionary.com: BTW, FYI.

While we’re at it, here are a few other common ones - LOL, AFAIK, AFAIR, YMMV, IRL, IDK.

Internet slangs are sometimes used even in non-English forums and chats, due to them being “common knowledge” among the people present in said forums/chats. “LOL” and “BTW” are particularly popular. In fact, you’ll notice the text of the " :laughing: " emoticon is “lol”.

Both we have express own opinion,
thanks to be polite.

What a battle here! Even the abbreviations are usually well known, it is better to avoid them and write as nice as possible.

Sent from Android by Tapatalk.

Battle?!? Wait. Who? Me? Noo…

When you say “nice”, do you mean as in “polite” or as in “elegant”? Because I think I’m being polite… though maybe I’m not always elegant. Certainly not in this instance. Though in my defense, it’s a non-elegant issue that brought my attention, making it easy to loose any elegance in writing about it.

Battle was kind of hyperbole. I was surprised what discussion could start one BTW. Yes, I mean both even I agree with you. Anyway it seems we have lost the topic which is also my fault. Sorry for that. Have a nice day!

Sent from Android by Tapatalk.

“Sent from Android by Tapatalk” is also an in-post thing :slight_smile: