this is a joke but regex is literally the simplest computing machines there could be. theyre mathematically equivalent to finite state machines so you can represent such acceptor as a non deterministic finite automata (which is also sometimes done). compared to a turing machine or a turing complete language (computers, programming language) an acceptor is simpler
Basic RegEx is easy. If you are good developer, you can understand basic RegEx.
The complex ones are just hard to read, but writin is sort of easy. Sometimes you need more time, but nothing above average daily tasks level of complexity.
What is confusing is that not all places allow all RegEx features, this may confuse a lot. Especially some systmes do not honor ^ and $.
Honestly, regex is one of the few areas I can see Ai being useful. Translate this statement, or create a statement that does this... Right at copilots strengths
Fully testing a regex string is rough if it's complicated.
I suspect that something I can explain will be much more likely to work right. In my field (embedded/FPGA) every time I have our internal GenAI tool generate stuff, it can't even stick to the specified language much less write it correctly.
Wayyy back in the day. One of my first task on a job was to write a script that split up an incoming email header (not just the address) and validated each piece of it. I mostly did it in regex. It was an interesting learning project. OF course, it was never actually used, and really just a project to keep me busy as part of onboarding. I wish I had kept that code.
Ah, I don't think it'd save me time to have to consult a cheat sheet for find/replace stuff in code. I'd be a lot more careful if I was putting regex into code though tbf.
Actually learning regex was one of the best things i’ve ever done. It’s not super complicated and there’s not that much to learn. About as hard as learning the basic keywords and syntax of a new programming language.
The downside is that it makes all the “now you have two problems” people sound dumb to you and you start feeling a little bad for being judgy but ffs it’s not that hard 🤦♀️
Tbh there are enough cheat sheets and generators that I look at memorizing it like memorizing any doc. It’s good to have a rough understanding, but knowing it without consulting something is pure overkill imo.
While I agree with you from a productive POV (regex is an on-demand thing, rarely involves reading someone else's regex lol), the person you're responding to seems to like it just for the sake of learning it which should be applauded I think
The trick with regexes is to learn what each and every symbol does. Learn a few common ones, and make sure you've really got it what each one means. Then, if you see a new symbol in something you are reading, stop, go to the docs, and make sure you understand what that new symbol means.
If you do this consistent, then you can always be confident when reading a regex. It will be slow at first, but you will always get there.
Regular Expressions were not difficult for me, when I took the course “Principles of Compilation” in my undergraduate years together with the CS majored students in my university.
I perfectly understand RegEx and how to use it and whenever there is an opportunity to utilize this skill, I realize I should probably just find another way because someone in the future will hate me for it.
136
u/LogicalExtension8822 Feb 09 '26
That's a bold lie, nobody understands regex
51
u/tiredITguy42 Feb 09 '26
Basic RegEx is easy. If you are good developer, you can understand basic RegEx.
The complex ones are just hard to read, but writin is sort of easy. Sometimes you need more time, but nothing above average daily tasks level of complexity.
What is confusing is that not all places allow all RegEx features, this may confuse a lot. Especially some systmes do not honor ^ and $.
14
u/AliceCode Feb 09 '26 edited Feb 10 '26
/r/firstweekcoderhumor
17
u/schizbouncer Feb 09 '26
Honestly, regex is one of the few areas I can see Ai being useful. Translate this statement, or create a statement that does this... Right at copilots strengths
4
u/Kaffe-Mumriken Feb 09 '26
I’ve stopped using regex 101. I only use ai
4
u/Cephell Feb 09 '26
Go ahead OP,
post your email validation regex in the comments
:)
4
u/Iron_Jazzlike Feb 10 '26
regex is so cool. i want every single search tool to have regex
7
u/ChrisBot8 Feb 09 '26
As a person that has been in the industry for over 10 years, why would you ever take the time to learn regex by sight?
2
u/Tombear357 Feb 09 '26
Well, it’s different based on what tool / code you’re using, sooo…
2
u/merRedditor Feb 09 '26
The next step is to be able to speak in regex when conveying variable concepts.
2
u/LetUsSpeakFreely Feb 09 '26
Never, ever allow a large, complicated regex to just be shoved into a single value.
2
u/Dillenger69 Feb 10 '26
Study? I learned regex by using it. over, and over, and over ...
And I STILL need a cheat sheet or https://regexr.com/
2
u/ohkendruid Feb 10 '26
I am surprised by the comments here.
The trick with regexes is to learn what each and every symbol does. Learn a few common ones, and make sure you've really got it what each one means. Then, if you see a new symbol in something you are reading, stop, go to the docs, and make sure you understand what that new symbol means.
If you do this consistent, then you can always be confident when reading a regex. It will be slow at first, but you will always get there.
Then, over time, it gets faster.
1
u/alucinario Feb 09 '26
just vive it
1
u/gameplayer55055 Feb 09 '26
Now write some good HTML parser using your knowledge
1
u/NichtFBI Feb 09 '26
Sometimes I typed out a complex regex like I'm typing words, and I went "when tf did this happen, I hated regex."
1
u/ByteBandit007 Feb 10 '26
Not even chatgpt gets it
1
u/[deleted] Feb 10 '26
Regular Expressions were not difficult for me, when I took the course “Principles of Compilation” in my undergraduate years together with the CS majored students in my university.
1
u/Forsaken-Pomelo4699 Feb 11 '26
I perfectly understand RegEx and how to use it and whenever there is an opportunity to utilize this skill, I realize I should probably just find another way because someone in the future will hate me for it.
1
u/anyway200894 Feb 12 '26
it only makes sense when i wrote it
if i have to "fix" it i would rather delete entire thing and start from the beginning
1
u/thebasicowl Feb 13 '26 edited Feb 13 '26
Hot take. You should never use regex.
The reason why I'm saying that is that it could lead to ReDoS attack(kind of DoS) if not used correctly.
This is not depending on how good developer you are, in my opinion you should never use it for a application.
1
u/coinjack010 Feb 14 '26
You've got graduated, 'altanative rep '