Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post2.news.xs4all.nl!newszilla.xs4all.nl!not-for-mail From: Eric Bednarz Newsgroups: comp.lang.javascript Subject: Re: ScreenName validation Organization: Eric Conspiracy Secret Labs References: <53ccd13b-a933-4bbc-ba0a-7061cc9064cd@4g2000yqv.googlegroups.com> Reply-To: ebednarz@gmx.net X-Eric-Conspiracy: There is no conspiracy Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Date: Sat, 12 Jan 2013 00:54:21 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (darwin) Cancel-Lock: sha1:3X0WJftReilcyL+9Xfk+35mE7Yk= MIME-Version: 1.0 Lines: 30 NNTP-Posting-Host: 83.163.169.80 X-Trace: 1357948463 dreader34.news.xs4all.nl 580 83.163.169.80:52692 Xref: csiph.com comp.lang.javascript:18080 Stefan Weiss writes: > On 2013-01-11 23:23, Eric Bednarz wrote: >> Stefan Weiss writes: >> >>> Could you give an example of when the literal ] character doesn't have >>> to be escaped in a character class? >> >> I'm not sure what you are asking. > > I may have misunderstood what you wrote. I interpreted it as: "the > literal ] has to be escaped because empty character classes are legal in > ECMAScript". Don't you agree with that in your final statement: |> Actually, now I can't think of a language other than ECMAScript that |> supports empty classes, so "many implementations" was probably wrong. ? > So, I think it would be better to say that ] always has to be escaped, > except in this one specific edge case (which cannot occur in ECMAScript). As far as I'm concerned, it's no more of an edge case than not escaping `^' if it's not at the start of a character class, and not escaping `-' if it's at the beginning or end of a character class, or right after the negator. It just looks more obscure, but if you're not in the two problems camp and think about REs in general, I would consider the `pattern' itself common knowledge.