Alright nerds, who can guess what this RegEx matches?

3 months ago by Pastel to c/programmer_humor

(?i)\b((?:(?:[a-z][\w-]+:)?(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))
xombie21 61 points 3 months ago

That's John Gruber’s regex pattern for matching URL's (⌐■_■).

path: 0 22589651, hotness: undefined, score: 61, children: 1
erayerdin 3 points 3 months ago

truly a sunglasses moment indeed

path: 0 22589651 22642923, hotness: undefined, score: 3, children: 0
marlowe221 58 points 3 months ago

This is an example of the old adage that “When you use a regex to solve a problem, you end up with two problems.”

path: 0 22591481, hotness: undefined, score: 58, children: 0
neidu3 44 points 3 months ago

Looks like an URL matcher of some sorts, not limited to HTTP. Kudos for handling parentheses as valid URL characters.

path: 0 22590129, hotness: undefined, score: 44, children: 5
refalo 25 points 3 months ago

URLs can have newlines too

path: 0 22590129 22590427, hotness: undefined, score: 25, children: 4
hoshikarakitaridia 29 points 3 months ago

/unlearn

path: 0 22590129 22590427 22598124, hotness: undefined, score: 29, children: 1
Venator 4 points 3 months ago

It seems most browsers basically ignore them:

https://lemire.me/...

So probably not worth remembering anyway.

path: 0 22590129 22590427 22598124 22615603, hotness: undefined, score: 4, children: 0
Sphks 7 points 3 months ago

What. The. Fuck.

path: 0 22590129 22590427 22604125, hotness: undefined, score: 7, children: 0
Quantenteilchen 2 points 3 months ago

Also no encoded basic auth or raw ip addresses (not that a useful website would likely use raw ipv4 or 6 since that causes huge CORS and sometimes even DNS issues...)

path: 0 22590129 22590427 22598315, hotness: undefined, score: 2, children: 0
bleistift2 23 points 3 months ago
As visualized by Regex Vis [1]

As visualized by Regexper [2]

The regex fucks with the markdown, so I had to put them in code tags:

[1] https://regex-vis.com/?r=%5Cb%28%28%3F%3A%28%3F%3A%5Ba-z%5D%5B%5Cw-%5D%2B%3A%29%3F%28%3F%3A%2F%7B1%2C3%7D%7C%5Ba-z0-9%25%5D%29%7Cwww%5Cd%7B0%2C3%7D%5B.%5D%7C%5Ba-z0-9.%5C-%5D%2B%5B.%5D%5Ba-z%5D%7B2%2C4%7D%2F%29%28%3F%3A%5B%5E%5Cs%28%29%3C%3E%5D%2B%7C%5C%28%28%5B%5E%5Cs%28%29%3C%3E%5D%2B%7C%28%5C%28%5B%5E%5Cs%28%29%3C%3E%5D%2B%5C%29%29%29*%5C%29%29%2B%28%3F%3A%5C%28%28%5B%5E%5Cs%28%29%3C%3E%5D%2B%7C%28%5C%28%5B%5E%5Cs%28%29%3C%3E%5D%2B%5C%29%29%29*%5C%29%7C%5B%5E%5Cs%60%21%28%29%5C%5B%5C%5D%7B%7D%3B%3A%27%22.%2C%3C%3E%3F%C2%AB%C2%BB%E2%80%9C%E2%80%9D%E2%80%98%E2%80%99%5D%29%29

[2] https://regexper.com/#\b((?:(?:[a-z][\w-]%20:)?(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()%3C%3E]+|\(([^\s()%3C%3E]+|(\([^\s()%3C%3E]+\)))*\))+(?:\(([^\s()%3C%3E]+|(\([^\s()%3C%3E]+\)))*\)|[^\s%60!()\[\]{};:'%22.,%3C%3E?%C2%AB%C2%BB%E2%80%9C%E2%80%9D%E2%80%98%E2%80%99]))

path: 0 22589548, hotness: undefined, score: 23, children: 2
Aatube 32 points 3 months ago

check out Regulex! it doesn't support mode modifiers but it does lack some features but i really like how its graphs look

path: 0 22589548 22589930, hotness: undefined, score: 32, children: 0
ulterno 1 point 3 months ago

Nice. Is there terminal/native running software with something similar?
Other than just running the HTML+JS/TS project in a container.

path: 0 22589548 22614367, hotness: undefined, score: 1, children: 0
pewpew 22 points 3 months ago

No

path: 0 22589461, hotness: undefined, score: 22, children: 0
vk6flab 16 points 3 months ago

At first glance IP address or URL, embedded in HTML, whatever it is, it's a doozy. I wonder what the performance of it is like.

path: 0 22589480, hotness: undefined, score: 16, children: 2
towerful 13 points 3 months ago

It works out as O(regex^n)

path: 0 22589480 22591143, hotness: undefined, score: 13, children: 0
tdawg 3 points 3 months ago

At least 2

path: 0 22589480 22590838, hotness: undefined, score: 3, children: 0
bleistift2 12 points 3 months ago

Whatever this is supposed to match, I bet the bycatch is bigger than tuna fishing.

path: 0 22590094, hotness: undefined, score: 12, children: 0
tamiya_tt02 11 points 3 months ago

Looks like the hacking mini game in Fallout 4.

path: 0 22598327, hotness: undefined, score: 11, children: 0
DarkSirrush 11 points 3 months ago

URLs in an HTML document that aren't namespaces or otherwise enclosed?

path: 0 22594824, hotness: undefined, score: 11, children: 0
sudoMakeUser 6 points 3 months ago

Hold on, let me draw up the NFA

path: 0 22589596, hotness: undefined, score: 6, children: 0
Olgratin_Magmatoe 5 points 3 months ago

:(

path: 0 22589771, hotness: undefined, score: 5, children: 0
kamikazerusher 5 points 3 months ago

Probably documents from HP’s atrocious support site

path: 0 22592749, hotness: undefined, score: 5, children: 0
NotMyOldRedditName 4 points 3 months ago

Is it a rick roll?

path: 0 22595148, hotness: undefined, score: 4, children: 0
irelephant 1 point a month ago

www
urls

path: 0 23667259, hotness: undefined, score: 1, children: 0
programmer_humor
programmer_humor

@programming.dev

login for more options
31938
2357
7362

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

go to feed...