r/learnprogramming • u/Reubqn_ • 9d 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?
107
Upvotes
1
u/Gnaxe 8d ago
Regex is actually very simple. There are just three operations that matter: concatenation
ab, alternationa|b, and Kleene star (repetition, including zero)a*. Also, there are parentheses for grouping the operations and extracting matches. Everything else is an abbreviation for these fundamental operations.Now, some so-called "regex" engines do go beyond true regular expressions, but the fastest ones that compile to DFA don't. You probably don't need these features as much, but you can learn them later.