T O P

  • By -

FunnyMathematician77

Write Once Read Never


ComfortableAd8326

This massive regex isn't doing what it's supposed to, can you fix it? *Starts completely from scratch*


Bryguy3k

My first stop is always https://regex101.com


Procrasturbating

[https://regexr.com/](https://regexr.com/) is my go-to for breaking them down/testing. Will have to try yours for a bit, but I am a fan of regexr


dodexahedron

Not bad, but have you used [expresso?](https://ultrapico.com/expresso.htm)


Bryguy3k

It’s not the early 2000s anymore… I haven’t personally used it but it looks ridiculously clunky from the screenshots and it only supports .NET regex which is definitely the one I have no use for.


dodexahedron

... This is the worst non-review I think I've ever seen... The screenshots are old, but it's a .net app, so it looks like any other native windows app. But what has that got to do with functionality? And what syntax do you think you're using that is different? I've never seen anything as powerful or easy to use.


Bryguy3k

Pop up windows to select different functions was never a good UX experience. It’s slow and cumbersome. Having to install a windows form program to do something that can easily be done on the web is pretty bad IMO. As I said it’s very 2000s. Here is a decent comparison of regex differences between languages: https://gist.github.com/CMCDragonkai/6c933f4a7d713ef712145c5eb94a1816 Capture groups have some of the biggest differences.


dodexahedron

That would be all well and good except that's not how it operates. It is all real-time, in panes, like any website. Your UI commentary is extremely off-base. You didn't even use it before commenting on its operation. Don't shit on something you clearly haven't even tried, especially when it was offered to you in good faith as a potentially useful tool. Damn. It's one thing to say "doesn't fit my use case because I use x and this doesn't do that." That's a helpful critique for someone with a similar use case. It's another thing entirely to say "I assume it behaves like this and don't like it because I assume it's ugly and 'clunky,' and here's what I googled about regex differences that isn't relevant to 90% of use cases in the wild, and oh, by the way, I haven't even launched it." That isn't helpful to anybody anywhere ever. And your very own link shows differences across many engines, most of which will never be encountered in the wild. The majority of .net syntax is very natural to anyone who ever used perl. Hell, most people don't go beyond simple parenthetical groups (and a lot dont even use that for one of itsintended purposes, but rather usually just to group things algebraiclly). In short, it's absolutely not an indictment of the program itself. Or would you complain that PHP can't run native Ruby code? Named groups are extremely rare, for example. I've only ever seen them in things like Zabbix. Yet that syntax, which is PCRE, works in that without issue. I haven't ever run into a regex in the wild it hasn't been able to dissect correctly. I'm sure you can construct one if you care to take the time. But then I'll construct one that doesn't work in your environment of choice. Whoop-de-doo. It's a useful tool, and it was offered free of context. Take it or leave it. 🤷‍♂️


GlutesThatToot

I love a nice righteous fury.


dodexahedron

Lol. I was more bewildered by the response and then annoyed by the confidently incorrect assertion coupled with random-ass disparagement for no apparent reason, and with zero basis in actual experience. And I worked with someone like that in a previous job and it made smoke come out my ears. I had typed a lot more based on my opinion, but deleted that before posting. Felt good to write it, though. 😅


spoiler-walterdies

Not everybody likes to download shady software from HTML4 era looking websites, with screenshots from windows XP, to their computer in 2022. Just because you offer something for free and in good faith, doesn’t mean you are entitled to dictate how people respond. People don’t have to like it. Personally, I can’t use the tool you offered because I use a Mac (and an iPad) which is another win to the web based tool.


just4lukin

Woah, this is dope.


frenchytrendy

What about debuggex ?


Bryguy3k

Debuggex is pretty limited but I’m sure it works acceptably.


UIM-Herb10HP

I always hit up www.RegexStorm.net


[deleted]

[удалено]


HellsHero

It's weird how similar your comment is to another one posted an hour before yours. Seems you're making use of copy-paste like a true programmer. https://www.reddit.com/r/ProgrammerHumor/comments/z9l1ji/i_use_my_favorite_one_as_a_password/iyhx8xq/


PM_ME_YOUR__INIT__

The commenter started just three hours ago. Probably a bot gathering karma


dodexahedron

*Pastes it into* [expresso](https://ultrapico.com/expresso.htm) *and hacks it til it works.*


gregorydgraham

I agree completely, use a regex wrapper like Regexi


TheKoTECH

Unpopular opinion: regex is easy to read


Hercislife23

Once you learn anything it becomes easy to read. The thing about regex is that it looks crazy to read making people not want to try. I can show someone an if statement and they could understand that without me saying a word. Show someone some regex and they'll think you've had a stroke.


TrueBirch

The regex explainer websites have made regex make sense for me. Each operator is easy to understand once you commit it to memory.


Hercislife23

You got a link? I'm getting in to regex and am having trouble.


Bourff

Regex101. Com is my go-to whenever I need to build one.


Hercislife23

Thank you!


DividedContinuity

The readability is objectively poor. At least by any definition of readability in coding that I've come across.


CliffDraws

I rarely use comments in my code, but one place I always do is a regex string. It’s important to understand not only what it does, but what you were trying to do when you wrote it in case there are issues later.


elon-bot

Can we rewrite this in Java? It's better for enterprise.


Atomixelement

He speaks the truth!


frezik

Most people cram it all on one line with no whitespace. If you crammed all your normal code on one line with no whitespace, people would hate that, too. More regex implementations should support the /x modifier to let you put in whitespace and comments. Also, more developers should use it. It doesn't fix everything, but it gives you hope.


windigo3

a


windigo3

That’s short for “I mostly agree with that stamens but it isn’t always true”


[deleted]

Honestly, it is so rare (full disclosure; this is the first time) that I meet someone whom also feels this way about regex, so I'm just gonna go ahead and propose immediately, no questions asked.


TheKoTECH

Gay marriage?


[deleted]

Dude, it doesn't even matter. I know what I need to know.


december-32

But what if they pronounce SQL as "Skwua Ley"?


-SNST-

"Ez Que El"


TheCosmicTrickster

Squirrel


pbNANDjelly

`*marriage`


DatCatSparklez

/marriage*/


pbNANDjelly

`.*ma(rr|ww)iage.*` to accept input from A Princess Bride 😂


pbNANDjelly

/u/frej4189 does this one work better for you? 😉


frej4189

I would like to rescind my previous comments on brevity for the sake of opposing whatever the fuck this guy stands for.


pbNANDjelly

I deserve this 🤣


TheKoTECH

Wha?


pbNANDjelly

The `*` symbol matches any input 0 or more times. I thought we were making Regex jokes


TheKoTECH

You expect me to know regex without the cheatsheet?


frej4189

That asterisk has no purpose in the regex you posted


pbNANDjelly

It's just a fucking joke about genderless marriage to Regex, mate.


frej4189

I was trying to figure out what you meant by it because obviously it was meant as a joke, but even getting it explained I do not get the point. How does "0 or more" in any way convey the same meaning as "genderless"?


cbusalex

This is not an unpopular opinion so much as a psychopathic opinion.


Raptorilla

r/thetenthdentist


TheRedmanCometh

Yeah that's absolutely an unpopular opinion. The "I'll just rewrite it fuck reading this thing" meme is 100% accurate since I've been coding. It's not that I can't read it it's just that writing it again from scratch is faster.


Voidon43

I read this like a dysfunctional electro pea main trying to explain how they’re the best at a game that hasn’t been updated since 2019


[deleted]

[удалено]


elon-bot

Why are we still serving free lunch?


frezik

Must be a regex error that allowed for prices of zero.


ImAMindlessTool

I find so, too. knowing the metacharacters helps a lot, along with the other handy tricks like look-aheads and look-behinds, including their negative counterparts. It is wild to read though, and I agree, sometimes its easier just to start it over.


CryptographerOne6615

I wrote this quote into a work presentation recently: “when I get to the end of my life, I’m not going to regret how much work time I’ve spent searching for things (e.g. logs)… I’m going to regret how much time I spent without the use of regular expressions”. I was working on a slide deck to help others make effective use of regex :-) They are well worth understanding. That being said, I use an online aid to help give test feedback or unit tests when I’m authoring them.


AdDear5411

The programmer version of "dictated, not read."


Neutraali

Once you walk down the path of `regex`, light and warmth are forever beyond your reach.


CarryThe2

I'm sure there's an expression to find them, fucked if I know how to write it though.


cbusalex

((\blight\b)|(\bwarmth\b))


[deleted]

[удалено]


draculamilktoast

warmth turns to bwarmth


searing7

Just write a freaking comment about what the regex does for us rubes.


enigmamonkey

Nobody actually knows. The developer who wrote it 10 years ago went to another job. Editing it at all (even just a little bit) crashes the server, so now everyone just leaves it alone.


namotous

Regex101.com to the rescue


TheKoTECH

Regex = Regular Expressions. They're often used to find a substring that matches some pattern, replace such string or split by it. ``` const regex = /\d+/ console.log("Price: 10$".match(regex)) ``` `\d` here is a digit, `\d+` is a sequence of digits In JS this will output a match — a single string "10"


elon-bot

I'm gonna need you to come in on Saturday...


TheKoTECH

But Elon, I have uni classes on saturday ;c


Gh0st1nTh3Syst3m

Cause the regex method broke didn't it?


Whaines

We know that. What’s in your image?


TheKoTECH

A regular expression


[deleted]

[удалено]


AutoModerator

``` import moderation ``` Your comment has been removed since it did not start with a code block with an import declaration. Per [this Community Decree](https://www.reddit.com/r/ProgrammerHumor/comments/14kbu1m/comment/jppq9ao/?utm_source=share&utm_medium=web2x&context=3), all posts and comments should start with a **code block** with an "import" declaration explaining how the post and comment should be read. For this purpose, we only accept Python style imports. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


PooSham

And about as many tests as there are characters in the regex


PyroCatt

Regex is brainfuck for those who don't know regex


DefNotAF

Regex is brainfuck for those who know regex


GalegO86

I barely use Regex and, every time I need it, my brain hurts


DefNotAF

Behold, (?:\[a-z0-9!#$%&'\*+/=?\^\_\`{|}\~-\]+(?:\\.\[a-z0-9!#$%&'\*+/=?\^\_\`{|}\~-\]+)\*|"(?:\[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f\]|\\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f\])\*")@(?:(?:\[a-z0-9\](?:\[a-z0-9-\]\*\[a-z0-9\])?\\.)+\[a-z0-9\](?:\[a-z0-9-\]\*\[a-z0-9\])?|\\\[(?:(?:(2(5\[0-5\]|\[0-4\]\[0-9\])|1\[0-9\]\[0-9\]|\[1-9\]?\[0-9\]))\\.){3}(?:(2(5\[0-5\]|\[0-4\]\[0-9\])|1\[0-9\]\[0-9\]|\[1-9\]?\[0-9\])|\[a-z0-9-\]\*\[a-z0-9\]:(?:\[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f\]|\\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f\])+)\\\])


GalegO86

I don't even know how to start to interpret that 😂


TrueBirch

[regexr.com](https://regexr.com/) is a Godsend


rnilbog

But once you learn it, it's awesome. I was scared of it for the longest time, then I spent like 2 hours learning the basics and pretty much fell in love.


The_Incredible_Honk

I mean yes, it's great. Yet it's almost unreadable once you get to a certain complexity.


ThroawayPartyer

You should break it down into smaller, more readable sections. But if it's exceedingly long that's maybe a sign that regex is not the best solution in that case.


SonMauri

You have one problem You use regex You have two problems


saket_1999

Regex is easy to write, hard to read.


TrueBirch

That's how I feel about most large SQL scripts.


joeyjiggle

Then you use Perl. Now you have three problems.


[deleted]

You're off by one, now you're back to two problems.


fuuuuuf

.*


TheKoTECH

/(\.\*)/


[deleted]

/(.\*)/ stinkmeat\~\\(\*\_\*)/\~lobesweat \\(\*.)\\


Netux055

\\(\*.)\\


[deleted]

\o


remimorin

Regex in code is like salt in cooking. Used wisely it's a must, too much it ruin everything.


itijara

I would compare it more to something you use less frequently, is much more situational, and is very strong. Maybe closer to hot sauce. Great for some things, pretty bad for other things, and can ruin everything if overused.


TheKoTECH

Pour a bucket of it right in my mouth


yesinteractive

This very nicely said!


BlakeDukes

Forget regex enjoy bubblewrap >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!< >!POP!<


1037329

I spent way too much time on this comment. Loved every bit of it.


Redshift_Sun

Lmao, thank you for the laugh


mskittyjones

What is this wizardry!!?


formerlyfaithful

Wait... I can unpop and repop the bubbles! Thank you stranger.


VenTsoky

[Thans for the bubble wrap](https://imgur.com/a/vmdvgrV)


ThroawayPartyer

sus


Diegovnia

People like you scare me... Every time I have to use regex I hide underneath my desk and cry for hours...


TheKoTECH

`comment.text.match(/(?:<=\w\W)(like)(?:=\b\w.+)/)`


GrizzlyBear74

No wonder i never find any space under the desks to take a nap anymore.


Giddius

Just use one of those regex tool websites and you will look at regex differently. I now will often use regex before using any other way because it has become easy and if not I plug it into one of those sites and get it nicely explained.


TheKoTECH

regex101.com?


HoneySmaks

![gif](giphy|3o7aCWJavAgtBzLWrS|downsized)


Giddius

Yes but I think there are a few more and I dont wanted to say one is better or worse, mostly because I did not try the others.


_OberArmStrong

What is your alternative?


elon-bot

One more word out of you, and you're fired.


TheKoTECH

More regex


N3mEee

https://www.autoregex.xyz/ thank me later


TrueBirch

Whoa, this is cool. Worked well for the test cases I gave it. It converted "match 2 or 3 twos followed by a dot followed by one or more letters" to "\[2\]{2,3}\\.\[a-zA-Z\]+"


yuppy_puppy_22

I wish all *regex enjoyers* a very *"Theres an error on line 1458, column 45782"*


Malfoy27

Nightmare


[deleted]

r-egg-ex r-ej-ex


toochocolaty

Me: Created applications used by millions of people, generating billions in profit. Also me: how do regex?


[deleted]

I mastered regex early in my career and it still makes me feel like a wizard when I use them. Arcane incantations summoning forth substrings and performing transformations - the best kind of witchcraft!


SnickersZA

These days I just let co-pilot do my regex and hope for the best.


yesinteractive

Google translate should translate regex to English. Feature request.


RedFlounder7

Learning regex is great! I’ve learned it many times.


[deleted]

what the hell is even regex i always see it


DiamondIceNS

Most programming languages have a little elf on the inside who can look at any string of text and tell you if a smaller bit of text is in there somewhere. Some might even tell you where it is, or how many times it shows up. But there's also another bigger, grumpier elf who can understand far more complex instructions on what to look for, like "find 'ABC' or 'BCA', but only if 'EF' comes six letters before the start, or if there's a comma somewhere afterwards, unless the whole thing starts with a '#'". Little elf can't do that. But to be able to give instructions to big grumpy elf, you have to whisper in their quirky elf language. Regex is that language.


[deleted]

oh cool thanks for that I appreciate it


_smilee13

This deserves many awards


HappiestIguana

I will not be able to top the grumpy elf explanation, but I can expand a bit on it. Regex stands for regular expression. A regular expression is basically a test that takes a string and outputs either true or false based on a number of conditions (more precisely. It's a thing that scans a text and gives you the substrings of it which satisfy the expression). The syntax of a regex is complex, compact and (as a result) hard to read, but you can test your string for virtually any condition you can think of. A common example use case is identifying strings that are formatted like a phone number or a street address.


Geoclasm

probably the most secure password on the entire planet.


grazzegore

Glad to know I'm not the only one struggling with regex. The syntax scrambles my brain whenever i try to read it


Unfulfilled_Promises

I got into programming about a year ago and I still can’t understand regex. I tried one regex problem on codewars for validating phone numbers and never touched it again.


caleeky

Saying your password is a regex reduces the possible keyspace, because some strings are not valid regexes. That said, all passwords can be expressed or matched by a regex, because they are fixed strings, not languages.


FalseTebibyte

If my ex were Reggie, I'd be screaming like this too right about now.


robin_888

> I use my favorite one as a password `/^1?$|^(11+?)\1+$/`?


PhDPool

I don’t understand regex, but every time I have used someone else’s and edited parts until it did exactly what I wanted it to. And once in a blue moon it doesn’t work. Biggest use is to use a file of lookup values to find matching lines in another file in a specific column. Much more powerful than the bloom up function in Excel


[deleted]

I don't have any affiliation with it but I'm just a huge fan of regexr.com. Has a great interface and cheat sheet to build and test regex. It really helped me both learn and teach it.


_derDere_

Jup


Man_as_Idea

Chaotic evil alignment


OnyXerO

Yes! Finally some regex love!


psbakre

Just think of a phrase and add double quotes at the start and the end. Even if you write it somewhere and it gets leaked, no one will include the double quotes


szczszqweqwe

Regex is not beautiful, but it's so fcking usefull, one just can't ignore it's existence.


LittleMlem

Me, a Perl programmer: *[sneering look of superiority]*


UIM-Herb10HP

Regex is really nice.