Or even better: `(?]**foo)` ("]" still terminates character classes; "**"
is a less ugly normally-invalid sequence).
On Tue, Dec 5, 2017 at 11:25 AM, <richard.gib...@gmail.com> wrote:
> Reviving this [thread] a third time, is there any love left for
> introdu
Reviving this [thread] a third time, is there any love left for introducing
RegExp.escape? The previous attempt was abandoned because of a so-called
"[even-odd problem]", but that can be fixed: backslash-escape every
_SyntaxCharacter_, then wrap the full result in a new form of non
Reviving this [thread] a third time, is there any love left for introducing RegExp.escape? The previous attempt was abandoned because of a so-called "[even-odd problem]", but that can be fixed: backslash-escape every _SyntaxCharacter_, then wrap the full result in a new form of non-captu
On Mon, Jun 29, 2015 at 9:04 PM, Benjamin Gruenbaum
benjami...@gmail.com wrote:
Why? What advantage would it offer?
See Scott’s previous email:
On Mon, Jun 29, 2015 at 8:42 PM, C. Scott Ananian ecmascr...@cscott.net wrote:
Imagine trying to ensure that any characters over \u007f were
escaped.
I'm still not sure if it's worth it, after all it's just sugar for
`RegExp.escape(str).replace(/[a-z]/gu, m = `\\${m}`)`
On Tue, Jun 30, 2015 at 10:35 AM, Mathias Bynens mathi...@opera.com wrote:
On Mon, Jun 29, 2015 at 9:04 PM, Benjamin Gruenbaum
benjami...@gmail.com wrote:
Why? What
On Tue, Jun 30, 2015 at 3:46 AM, Benjamin Gruenbaum benjami...@gmail.com
wrote:
I'm still not sure if it's worth it, after all it's just sugar for
`RegExp.escape(str).replace(/[a-z]/gu, m = `\\${m}`)`
I think you're making my point! And I hope your version of `RegExp.escape`
doesn't use
Why? What advantage would it offer?
On Mon, Jun 29, 2015 at 9:49 PM, C. Scott Ananian ecmascr...@cscott.net
wrote:
And I'm suggesting that `RegExp.escape(str, /[image: ☺]/ug)` is a much
better idea.
--scott
___
es-discuss mailing list
es-discuss
On Jun 27, 2015, at 9:17 AM, Mark S. Miller wrote:
Safety over readability please. If there is a single fully escaped form that
is safe to use in all the expected contexts, let's choose that. The results
of RegExp.escape are not very readable anyway, and rarely read. So
compromising
And I'm suggesting that `RegExp.escape(str, /[image: ☺]/ug)` is a much
better idea.
--scott
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
This is currently discussed at
https://github.com/benjamingr/RegExp.escape/issues/29#issuecomment-116789780
.
Adding my comment from there to here too:
Some languages (PHP for example) do this (optional parameter with
additional parameters) so it's not unprecedented.
The question we should ask
Please, not an iterable over characters. (Or at least, not only.) Use a
RegExp. Imagine trying to ensure that any characters over \u007f were
escaped. You don't want an iterable over ~64k characters.
In addition, a RegExp would allow you to concisely specify hex digits, but
only at the start
I meant something like `RegExp.escape(str, ☺)` (also escapes `☺`). Since
strings are iterable by code points via the new iteration protocol this
sounds like the natural choice. I'm not sure such a second argument would
be a good idea.
On Mon, Jun 29, 2015 at 9:42 PM, C. Scott Ananian ecmascr
Safety over readability please. If there is a single fully escaped form
that is safe to use in all the expected contexts, let's choose that. The
results of RegExp.escape are not very readable anyway, and rarely read. So
compromising safety for some contexts in exchange for incremental
readability
I'd like to give https://github.com/benjamingr/RegExp.escape/issues/29
another week *please, if you have a strong opinion voice it* after which
we'll settle on a hopefully *final* API for RegExp.escape in terms of the
escaped parts.
Some parts so you won't have to read the whole thread (debated
As a cross-cutting concern I'd like the feedback of more people on
https://github.com/benjamingr/RegExp.escape/issues/29
Basically we've got to make a design choice of readable output vs.
potentially safer output.
___
es-discuss mailing list
es-discuss
...@gmail.com wrote:
As a cross-cutting concern I'd like the feedback of more people on
https://github.com/benjamingr/RegExp.escape/issues/29
https://github.com/benjamingr/RegExp.escape/issues/29
Basically we've got to make a design choice of readable output vs.
potentially safer output
Why is this a comment on the RegExp.escape discussion?
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
On Jun 13, 2015, at 1:18 PM, C. Scott Ananian wrote:
To throw some more paint on the bikeshed:
The instanceof RegExp and RegExp(...) parts of the perfect
implementation of `RegExp.tag` should also be fixed to play nicely with
species.
I think Allen and I would say that you should
On Jun 13, 2015, at 4:16 PM, Allen Wirfs-Brock wrote:
On Jun 13, 2015, at 1:18 PM, C. Scott Ananian wrote:
To throw some more paint on the bikeshed:
The instanceof RegExp and RegExp(...) parts of the perfect
implementation of `RegExp.tag` should also be fixed to play nicely with
Perfection?
function re(first, ...args) {
let flags = first;
function tag(template, ...subs) {
const parts = [];
const numSubs = subs.length;
for (let i = 0; i numSubs; i++) {
parts.push(template.raw[i]);
const subst = subs[i] instanceof RegExp ?
The point of this last variant is that data gets escaped but RegExp objects
do not -- allowing you to compose RegExps: re`${re1}|${re2}*|${data}`
But this requires one more adjustment:
function re(first, ...args) {
let flags = first;
function tag(template, ...subs) {
const
On Sat, Jun 13, 2015 at 1:51 AM, Mark S. Miller erig...@google.com wrote:
Nice! Inspired
// Based on
// https://github.com/benjamingr/RexExp.escape/blob/master/polyfill.js
function re(template, ...subs) {
const parts = [];
const numSubs = subs.length;
for (let i = 0; i
Good idea bug infinite recursion bug. Fixed:
function re(first, ...args) {
let flags = first;
function tag(template, ...subs) {
const parts = [];
const numSubs = subs.length;
for (let i = 0; i numSubs; i++) {
parts.push(template.raw[i]);
All of these should be building on top of RegExp.escape :P
From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Mark S.
Miller
Sent: Saturday, June 13, 2015 02:39
To: C. Scott Ananian
Cc: Benjamin Gruenbaum; es-discuss
Subject: Re: RegExp.escape()
The point of this last variant
] =
Object.freeze('^$\\.*+?()[]{}|'.split(''));` or something? Then @exec could
reference that, and similarly `RegExp.escape` and RegExpSubclass.escape`
could reference it as well?
On Sat, Jun 13, 2015 at 11:07 AM, Mark S. Miller erig...@google.com
wrote:
On Sat, Jun 13, 2015 at 9:17 AM
To throw some more paint on the bikeshed:
The instanceof RegExp and RegExp(...) parts of the perfect
implementation of `RegExp.tag` should also be fixed to play nicely with
species.
I think Allen and I would say that you should *not* use the species pattern
for instantiating the new regexp
On Sat, Jun 13, 2015 at 9:07 PM, Mark S. Miller erig...@google.com wrote:
On Sat, Jun 13, 2015 at 9:17 AM, Domenic Denicola d...@domenic.me wrote:
All of these should be building on top of RegExp.escape :P
It's funny how, by considering it as leading to a proposal, I quickly saw
deep
On Sat, Jun 13, 2015 at 11:39 AM, Benjamin Gruenbaum benjami...@gmail.com
wrote:
On Sat, Jun 13, 2015 at 9:07 PM, Mark S. Miller erig...@google.com
wrote:
On Sat, Jun 13, 2015 at 9:17 AM, Domenic Denicola d...@domenic.me wrote:
All of these should be building on top of RegExp.escape :P
:
On Sat, Jun 13, 2015 at 9:07 PM, Mark S. Miller erig...@google.com
wrote:
On Sat, Jun 13, 2015 at 9:17 AM, Domenic Denicola d...@domenic.me wrote:
All of these should be building on top of RegExp.escape :P
It's funny how, by considering it as leading to a proposal, I quickly
saw deep flaws
On Sat, Jun 13, 2015 at 9:17 AM, Domenic Denicola d...@domenic.me wrote:
All of these should be building on top of RegExp.escape :P
I am not yet agreeing or disagreeing with this. Were both to become std,
clearly they should be consistent with each other. At the time I wrote
this, it had
Would it help subclassing to have the list of syntax characters/code points
be on a well-known-symbol property? Like
`RegExp.prototype[@@syntaxCharacters] =
Object.freeze('^$\\.*+?()[]{}|'.split(''));` or something? Then @exec could
reference that, and similarly `RegExp.escape
I made an initial repo
https://github.com/benjamingr/RexExp.escape/blob/master/README.md
I've added a reference to that gist - I'll start poking around and have
scheduled to meet with some local people interested in helping next week.
I'll keep you updated.
On Fri, Jun 12, 2015 at 9:57 PM, Juriy
}|def${ /a reg|exp/
})$`
// apply flags?
var pattern = RegExp.join('x')` abc | def \$`;
```
`RegExp.escape()` would be used internally to handle the interpolation of
an string into the regexp. But these features are orthogonal.
--scott
On Fri, Jun 12, 2015 at 2:57 PM, Juriy Zaytsev kan
You know what? Why not. I'm going to try to champion this.
I talked to Domenic and he said he's willing to help me with this which is
a big help (this would be my first time).
I'll open a GitHub repo and see what I can come up with.
___
es-discuss
I made this gist back in the days — https://gist.github.com/kangax/9698100
— and I believe Rick was going to bring it up at one of the meetings. I
don't have time to set up repo and work with TC39 member so if you can
continue carrying that torch, that would be awesome!
--
kangax
On Fri, Jun
Nice! Inspired
// Based on
// https://github.com/benjamingr/RexExp.escape/blob/master/polyfill.js
function re(template, ...subs) {
const parts = [];
const numSubs = subs.length;
for (let i = 0; i numSubs; i++) {
parts.push(template.raw[i]);
Ok, with a ton of help from Domenic I've put up
http://benjamingr.github.io/RexExp.escape/
Less cool coloring but more links and motivating examples and so on at
https://github.com/benjamingr/RexExp.escape
As this is my first attempt at this sort of thing - any non-bikeshed
feedback would be
Reviving this, a year passed and I think we still want this.
We have even more validation than we had a year ago (added by libraries
like lodash) and this is still useful.
What would be the required steps in order to push this forward to the
ES2016 spec?
At risk of bikeshed, I think I would prefer syntax for it, personally, e.g.:
let myRegExp = /\d+\./{arbitrary.js(expression)}/SOMETHING$/;
(ASI issues notwithstanding) vaguely matching the idea of template strings.
I prefer this kind of thing to be structured at the parse-level rather than
The primary advantage to making it be a function (also doing it as syntax
would be great too!) is that it's polyfillable, which means that all
browsers could instantly take advantage of known-safe regex escaping.
On Fri, Jun 12, 2015 at 11:34 AM, Alexander Jones a...@weej.com wrote:
At risk of
I believe you need to champion the issue. Create a Github repository and
start editing the fragment of the spec. I do not believe that the issue is
contentious. The color of the shed is obvious. The only thing missing is a
champion willing to do the writing.
On Fri, Jun 12, 2015 at 10:52 AM,
:
RegExp.escape = function(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$');
};
It escapes some characters that do not strictly need escaping to avoid bugs in
ancient JavaScript engines. A standardized version could be even simpler, and
would indeed be very welcome IMHO
Continuing a 2 year old thread.
http://esdiscuss.org/topic/regexp-escape
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
Thanks for the back-reference, Kris. So, everyone seemed to be in
favor of this, it just never got formally added.
@rwaldron, are you interested in championing this for ES7 as well?
--scott
On Fri, Mar 21, 2014 at 12:09 PM, Kris Kowal kris.ko...@cixar.com wrote:
Continuing a 2 year old
On Fri, Mar 21, 2014 at 4:29 PM, C. Scott Ananian ecmascr...@cscott.netwrote:
Thanks for the back-reference, Kris. So, everyone seemed to be in
favor of this, it just never got formally added.
@rwaldron, are you interested in championing this for ES7 as well?
Not until someone writes
How about this -- https://gist.github.com/kangax/9698100
Made it loosely based on B.2.1.1 (escape)
--
kangax
On Fri, Mar 21, 2014 at 5:56 PM, Rick Waldron waldron.r...@gmail.comwrote:
On Fri, Mar 21, 2014 at 4:29 PM, C. Scott Ananian
ecmascr...@cscott.netwrote:
Thanks for the
expressions include a
built in method for this.
For instance:
* Perl: quotemeta(str)
* PHP: preg_quote(str)
* Python: re.escape(str)
* Ruby: Regexp.escape(str)
* Java: Pattern.quote(str)
* C#, VB.NET: Regex.Escape(str)
Indeed. +1 for RegExp.escape in ES.
-- T.J
: Regexp.escape(str)
* Java: Pattern.quote(str)
* C#, VB.NET: Regex.Escape(str)
Indeed. +1 for RegExp.escape in ES.
-- T.J.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
On Mar 23, 2012, at 8:16 AM, Steven Levithan wrote:
Although this is only a minor convenience since you can do something like
text.replace(/[-[\]{}()*+?.,\\^$|]/g, \\$), the list of special characters
is subject to change.
That sounds like another good argument for standardizing.
The only
On Wednesday, Jan 04, 2012 at 8:03 PM, Kris Kowal wrote:
On Sun, Jun 13, 2010 at 7:50 AM, Jordan Osete jordan.os...@yahoo.fr
wrote:
Hello everybody.
How about standardizing something like RegExp.escape() ?
http://simonwillison.net/2006/Jan/20/escape/
It is trivial to implement, but it seems
2012/3/23 Steven Levithan steves_l...@hotmail.com:
On Wednesday, Jan 04, 2012 at 8:03 PM, Kris Kowal wrote:
On Sun, Jun 13, 2010 at 7:50 AM, Jordan Osete jordan.os...@yahoo.fr
wrote:
Hello everybody.
How about standardizing something like RegExp.escape() ?
http://simonwillison.net/2006
Erik Corry wrote:
Steven Levithan wrote:
Kris Kowal wrote:
Jordan Osete wrote:
Hello everybody.
How about standardizing something like RegExp.escape() ?
http://simonwillison.net/2006/Jan/20/escape/
It is trivial to implement, but it seems to me that this functionality
belongs
: Regexp.escape(str)
* Java: Pattern.quote(str)
* C#, VB.NET: Regex.Escape(str)
-- Steven Levithan
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
On Sun, Jun 13, 2010 at 7:50 AM, Jordan Osete jordan.os...@yahoo.fr wrote:
Hello everybody.
How about standardizing something like RegExp.escape() ?
http://simonwillison.net/2006/Jan/20/escape/
It is trivial to implement, but it seems to me that this functionality
belongs to the language
Hello everybody.
How about standardizing something like RegExp.escape() ?
http://simonwillison.net/2006/Jan/20/escape/
It is trivial to implement, but it seems to me that this functionality
belongs to the language - the implementation obviously knows better
which characters must be escaped
55 matches
Mail list logo