by azalemeth · 5y ago · 0 comments
So, does this apply to URLs? The fact that these regexes are....so huge...makes me think that something is fundamentally wrong. Are URLs describable in a Chomsky Type 3 grammar? Are they sufficiently regular that using a Regex is sensible? What do the actual browsers do?
[1] https://stackoverflow.com/questions/1732348/regex-match-open...
URLs are not recursive structures, so I’d say the single hardest feature of html is not present.
There was a Perl program that would take something like a BNF and barf out a gigantic regex (maybe with some maximum depth).
Yes, if your regex is above {.../50/100/...} characters, then write parser.
I struggle to understand why do people write those crazy regexes for emails, urls, html when probably in all popular technologies there are battle-tested parsers for those things.
As an example, http://localhost/ is technically valid url, which he wants to block. Should this error say misformatted URL like all others?
Using regex to cover all such cases is really the wrong tool for the job.