3 ms·
But don't forget to point at the limitations. For example, you can't use regexps to match an arbitrary but equal number of nested opening and closing parenthese
by amelius 9y ago
But don't forget to point at the limitations. For example, you can't use regexps to match an arbitrary but equal number of nested opening and closing parentheses.
- oftenwrong 9y agoregex engines like PCRE can: ^(\((?1)?\))$
- swiley 9y agoIf it can then it's not "regular expressions."
- dozzie 9y agoWhich is very computer-science-y approach, and totally uninteresting at that, because the (?PARNO) syntax is still embedded in the same regexp engine for any practical purpose or distinction. If you didn't know, a regexp engine with capture groups is already stronger than what in formal languages theory is called "regular expressions".
- kbp 9y agoBut when most of the commonly used "regular expression" libraries aren't regular, I think if you really mean solving something with only regular expressions, you should probably specify that explicitly. The term's been corrupted enough that using it by itself to rule out things like backreferences isn't clear communication.
- loup-vaillant 9y agoThat's a shame, because regular grammars have a very important property: they're processed with a Finite State Automaton. This makes them blazing fast and quite memory efficient. (Heck, even with a non-deterministic one they're fast.)
- lr4444lr 9y agoI presume you're familiar with the infamous "can you parse HTML with regex"? https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags https://stackoverflow.com/questions/1732348/regex-match-open...
- amelius 9y agoAnother potential problem with regexps is that the underlying finite state machine can grow exponentially in the size of the expression.