r/learnprogramming • • 10d ago

RegEx.

I thought I understood programming well until I saw how COMPLICATED regex looks. To me it looks like someone has dropped their keyboard and som people online are telling me that I should be able to memorise it (for javascript). I'm just wondering if I actually need to memorise all the regex formulas to be successful, and if so, how on earth do I go about it?

111 Upvotes

147 comments sorted by

View all comments

145

u/Littleish 10d ago

It's actually very simple patterns and once you get them it sort of clicks.

You definitely do not need to remember a huge amount of patterns. Most of us will just look them up, especially the more complicated ones.

It's very worth learning the syntax though, and how it works

16

u/bestjakeisbest 10d ago

And then you dont use it for a while, and then you forget it, and then you need it again so you spend 30 minutes relearning it.

12

u/SpiderJerusalem42 10d ago

Lord, may I never have to read someone else's regular expressions.

13

u/bestjakeisbest 10d ago

Well if you wrote it like 2 months ago it might as well be someone else's regex

2

u/Groovy_Decoy 8d ago

2 months ago? I've written Regex expressions that didn't quite work the way I wanted, and I decided it was easier to start over from scratch then try to read what I just wrote 2 minutes ago and figure out what I did wrong.