4 ms·
> Am I the only person who thinks that things like this are totally unnecessary? Not unnecessary, “useless”, “kidding” are more appropriate words IMHO. Where
by lelf 13y ago
> Am I the only person who thinks that things like this are totally unnecessary?
Not unnecessary, “useless”, “kidding” are more appropriate words IMHO.
Where is named captures? Oh, you cannot. Well, ordinary $1 $2 $3? Oh, you cannot capture at all!
How do you use back refs? Oh, you cannot?
Wait, why the heck then you even need regexps?
There are problems with complex regexes, yes. But this silly toy is not the solution. For solutions look at Perl6's “regexps”, Perl6's Grammars (example down the thread), Perl5's Regexp::Grammars, look how Haskell do it with parser combinators. They are all light years ahead.
- krainboltgreene 13y agoOuch, thanks for the harsh words. But yes, 1.2 will likely have named captures and back refs. It's a regex, so $1 etc come with turning it into a regex and doing matching.
- lelf 13y agoOK then. But look at state of the art solutions I mentioned ;-) Perl5's R::Grammars is doing it the same way you do — it generates one-big-scary regex. But this lib is nowhere close to what it can do. For idea: it will provide fully parsed struct like {proto: 'http', domain: { all: 'www.exampe.com', subdomains: ['www','example'], tld: 'ord', ... }
- krainboltgreene 13y agoYou can do this with regex captures.
- lelf 13y agoIt's not $1="this", $2="that", it's a tree. So, no, you cannot. And there're many more cool things you cannot