News for hackers. Stuff that matters.
Re:ECMAScript regular expressions are getting better (2017) by Spivak on Wednesday November 28, 2018 @09:58AM (#18551984)
But backrefs are super useful though. I think it was a mistake to conflate what developers actually want, a DSL to detect the shape of data and extract portions of it, and the implementation detail of basing such a thing on regular languages.
Re:ECMAScript regular expressions are getting better (2017) by dbrgn on Wednesday November 28, 2018 @12:09PM (#18553261)
They are useful, but also a bit dangerous. Case in point, a few years ago I foolishly thought that I'd "just take a few minutes to fix the Django URLValidator". I picked up where someone else had failed a year previously (that should have warned me).

After a lot of time I finally got the test suite to pass and was happy, naïvely thinking that "if it passes the tests it must be correct". Unfortunately I also integrated a nice case of catastrophic backtracking into the regex that timgraham fortunately caught. This could have resulted in DoS-attacks against web forms that contain validated URL fields. (This is especially nice when doing it against non-asynchronous Python servers.)

https://github.com/django/django/pull/2873

This beast was finally merged half a year later:

^(?:[a-z0-9\\.\\-])://(?:\\S+(?::\\S)?@)?(?:(?:25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}|\\[[0-9a-f:\\.]+\\]|([a-z\u00a1-\uffff0-9](?:[a-z\u00a1-\uffff0-9-][a-z\u00a1-\uffff0-9])?(?:\\.[a-z\u00a1-\uffff0-9]+(?:[a-z\u00a1-\uffff0-9-][a-z\u00a1-\uffff0-9]+))\\.[a-z\u00a1-\uffff]{2,}\\.?|localhost))(?::\\d{2,5})?(?:[/?#][^\\s]*)?$

Re:ECMAScript regular expressions are getting better (2017) by mehrdadn on Wednesday November 28, 2018 @12:34PM (#18553519)
Meanwhile I DoS'd my own browser via my own Chrome extension once because of a regex... and it didn't even have a backreference.
Re:ECMAScript regular expressions are getting better (2017) by stplsd on Wednesday November 28, 2018 @10:00AM (#18551998)
I think we should just use term regex and leave term regular expressions for, you know, actual regular expressions.
Re:ECMAScript regular expressions are getting better (2017) by stochastic_monk on Wednesday November 28, 2018 @11:42AM (#18553000)
What should these be called? Context-free expressions?
Re:ECMAScript regular expressions are getting better (2017) by man-and-laptop on Wednesday November 28, 2018 @12:46PM (#18553694)
The language

    (.*)\1
is not context-free.

Also it's not clear if regexes with backreferences can parse XML, which is context-free.