3 ms·
uhh? just because you can doesn't mean you should just take a look at proposed regex >( > # match all tags in XHTML but capture only opening tags > <!-- .
by tester756 6y ago
uhh?
just because you can doesn't mean you should
just take a look at proposed regex
>(
> # match all tags in XHTML but capture only opening tags
> <!-- .? --> # comment
> | <!\[CDATA\[ .? \]\]> # CData section
> | <!DOCTYPE ( "" [^""]* "" | ' [^']* ' | [^>/'""] )* >
> | <\? .? \?> # xml declaration or processing instruction
> | < \w+ ( "" [^""] "" | ' [^']* ' | [^>/'""] )* /> # self-closing tag
> | < (?<tag> \w+ ) ( "" [^""]* "" | ' [^']* ' | [^>/'""] )* > # opening tag - captured
> | </ \w+ \s* > # end tag
> )
it's ugly as hell
>Parsing typically uses (at least) two steps: Tokenization which uses regular expressions to splits the input string into a sequence of syntax elements
I don't use regex for tokenization, I'm doing something wrong?
But overall I think this is important post, even despite I believe that regex is the best example of "good idea, shitty API"