Re:ECMAScript regular expressions are getting better (2017)
by couchand on Wednesday November 28, 2018 @10:54AM
(#18552462)
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:
[0]: https://coffeescript.org/#regexes
[ Parent
| on HN ]
Re:ECMAScript regular expressions are getting better (2017)
by pitaj on Wednesday November 28, 2018 @12:06PM
(#18553243)
Rust 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
")
Re:ECMAScript regular expressions are getting better (2017)
by burntsushi on Wednesday November 28, 2018 @01:00PM
(#18553856)
Yup! 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&editio...
Re:ECMAScript regular expressions are getting better (2017)
by DFHippie on Wednesday November 28, 2018 @12:27PM
(#18553436)
Another way to write more readable Rust regexen: https://crates.io/crates/pidgin
(I'm the author.)
Re:ECMAScript regular expressions are getting better (2017)
by scrollaway on Wednesday November 28, 2018 @01:15PM
(#18554038)
CoffeeScript sourced a lot of its design from Python. This is one of those.
Re:ECMAScript regular expressions are getting better (2017)
by skrause on Wednesday November 28, 2018 @05:22PM
(#18556235)
Python version: https://docs.python.org/3/library/re.html#re.VERBOSE