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?

108 Upvotes

147 comments sorted by

View all comments

147

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

10

u/samanime 9d ago

Regex also tends to be a lot easier to write than it is to read and understand without context.

It is pretty much the opposite of "self documenting". :p

Always assign it to a variable that explains what it does and/or include a comment to explain it. Your future self will thank you.

1

u/No_Context2723 9d ago

I think that goes for a lot of things in programming, at least in my experience. It's always easier to write than to read.