3

Given that an XML parser probably/should uses a regex to find the beginning ("<--") and end ("-->") of a comment, WTF can I not use "--" inside one?

Comments
  • 0
    try the unicode code hyphen-minus
    U+002D
  • 2
    Typo in my post, opening comment tag is missing the exclamation point.
  • 3
    First, not all parsers use regex. My parser for our templating solution do not since it has to handle some cases that regex is not well suited for, plain text mixed with script syntax, probably a bad script design decision in the beginning.

    Secondly xml is a standard designed long ago and parsers should not deviate from that standard.
  • 2
    @tachoknight awkward use of "wtf" -> "why the fuck" ???
  • 1
    @Divisionbyzero yeah sorry, I use WTF in a lot of contexts 😳
  • 1
    XML is not a regular language, so it's not parsed with regexes.
  • 0
    @willol no, but tokenizing often can use regex but if you have contextual differences you need different regex depending on context which can require tokenizing on demand which is a bit more complex.
Add Comment