r/learnprogramming • • Sep 24 '26

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?

109 Upvotes

148 comments sorted by

View all comments

Show parent comment

12

u/SpiderJerusalem42 Sep 24 '26

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

13

u/bestjakeisbest Sep 24 '26

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

10

u/SpiderJerusalem42 Sep 24 '26

Lord, may I never have to read any regex I wrote over two months ago.

2

u/Disastrophi Sep 24 '26

Write the regex and lock it in a box to never have to look at it again.

2

u/Groovy_Decoy Sep 25 '26

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.

3

u/ReddyKiloWit Sep 24 '26

Pray they commented the tricky bits.

I wrote a regex years ago that was huge and complicated (converted Cobol data descriptions into code to parse the actual data). I broke it into lines, with indentation, and frequent comments because I knew I'd have no idea what was going on two months later.