4 ms·
Clarification: I know how they work. What I -don't- bother keep in my head, is every metacharacter, character class (POSIX especially), assertions, string repla
by lostcolony 12y ago
Clarification: I know how they work. What I -don't- bother keep in my head, is every metacharacter, character class (POSIX especially), assertions, string replacement options, etc, because I can just look those up. The example mentioned above is actually a really good case of why I don't worry about remembering all the specifics; because it's really easy to screw it up. Oh, I forgot {} were special characters, because I have -never- used them (any time I needed repetition it was always so few times, and for a single character class, I just repeated the character in the pattern), so I forgot to escape them.
And let's not forget the implementation different specifics (the need to specify multiline matching as a separate parameter into the parser, \ vs $ for string replacement, etc)
In general, if I'm writing a regex more complicated then "Hey, does this string match this literal?" I'm going to pull up a cheat sheet, because it avoids issues like that. But the number of times it makes sense to do that is really, really low.
It makes as much sense to me to say you should remember all ASCII character codes. Why? If you know how they work, and you're not using them enough to remember all of them automatically, it's not really a problem to just look them up if/when you need them.