Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I always had a hard time remembering the regex syntax and form until I learned about scanners/lexers/tokenizers and finite state machines. Then it really clicked and made a lot of sense.


James Clark's compact syntax for Relax/NG XML schema validation language is quite tastefully designed, an equivalent but more convenient alternative syntax than XML, for writing tree regular expressions matching XML documents. It's way more beautiful and coherent than the official "XML Schema" standard.

https://www.oasis-open.org/committees/relax-ng/compact-20021...

RELAX NG compact syntax cheat sheet

https://gist.github.com/miikka/b137a8705e88b0b6c164

https://en.wikipedia.org/wiki/RELAX_NG#Compact_syntax

>RELAX NG compact syntax is a non-XML format inspired by extended Backus-Naur form and regular expressions, designed so that it can be unambiguously translated to its XML counterpart, and back again, with one-to-one correspondence in structure and meaning, in much the same way that Simple Outline XML (SOX) relates to XML. It shares many features with the syntax of DTDs. Here is the compact form of the above schema:

    element book {
        element page { text }+
    }
>With named patterns, this can be flattened to:

    start = element book { page+ }
    page = element page { text }
>A compact RELAX NG parser will treat these two as the same pattern.

There's a wonderful DDJ interview with James Clark called "A Triumph of Simplicity: James Clark on Markup Languages and XML" where he explains how a standard has failed if everyone just uses the reference implementation, because the point of a standard is to be crisp and simple enough that many different implementations can interoperate perfectly.

A Triumph of Simplicity: James Clark on Markup Languages and XML:

https://web.archive.org/web/20130721072712/https://www.drdob...

"The standard has to be sufficiently simple that it makes sense to have multiple implementations." -James Clark




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: