3 ms·
This was one of the places CoffeeScript really innovated, IMO (though of course Perl did it first). The "Block Regular Expressions"[0] allow whitespace and com
by couchand 8y ago
This was one of the places CoffeeScript really innovated, IMO (though of course Perl did it first). The "Block Regular Expressions"[0] allow whitespace and comments:
NUMBER = ///
^ 0b[01]+ | # binary
^ 0o[0-7]+ | # octal
^ 0x[\da-f]+ | # hex
^ \d*\.?\d+ (?:e[+-]?\d+)? # decimal
///i
[0]: https://coffeescript.org/#regexes https://coffeescript.org/#regexes
- pitaj 8y agoRust allows this too: Regex::new(r"(?x) (?P<y>\d{4}) # the year - (?P<m>\d{2}) # the month - (?P<d>\d{2}) # the day ")
- DFHippie 8y agoAnother way to write more readable Rust regexen: https://crates.io/crates/pidgin https://crates.io/crates/pidgin (I'm the author.)
- burntsushi 8y agoYup! rust/regex has had this for a while. More recently, its error messages have also gotten a lot better, which I'm proud of! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ regex parse error: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1: (?x) 2: (?P<y>\d{4}) # the year 3: - 4: (?P<m>*\d{2} # the month ^ 5: - 6: (?P<d>\d{2}) # the day 7: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: repetition operator missing expression ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=c9fb1d58a8132d57d66417752a0f7282 https://play.rust-lang.org/?version=stable&mode=debug&editio...
- scrollaway 8y agoCoffeeScript sourced a lot of its design from Python. This is one of those. https://docs.python.org/3/library/re.html#re.X https://docs.python.org/3/library/re.html#re.X
- skrause 8y agoPython version: https://docs.python.org/3/library/re.html#re.VERBOSE https://docs.python.org/3/library/re.html#re.VERBOSE