Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #18079

Re: ScreenName validation

From Stefan Weiss <krewecherl@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: ScreenName validation
Date 2013-01-12 00:26 +0100
Organization albasani.net
Message-ID <kcq72e$upp$1@news.albasani.net> (permalink)
References (3 earlier) <r1que89eftmfejrieqstmo7bp1ra3e92rv@4ax.com> <m2hamnqzr4.fsf@nntp.bednarz.nl> <m2obgvii6g.fsf@nntp.bednarz.nl> <kcpv2o$epv$1@news.albasani.net> <m2txqnicks.fsf@nntp.bednarz.nl>

Show all headers | View raw


On 2013-01-11 23:23, Eric Bednarz wrote:
> Stefan Weiss <krewecherl@gmail.com> 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".

You did identify a case where a literal "]" in a character class doesn't
have to be escaped, and that is when
a) it immediately follows the opening "[", and
b) the language does not support the empty class []

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).

>  Examples in other languages?
>
> $ php -r 'echo preg_match("/^[]]$/", "]"), "\n";'
> 1

Yes, but

$ php -r 'echo preg_match("/^[b]]$/", "b"), "\n";'
0

because the first ] ends the class. The same goes for the [snipped]
examples from other languages.

>> The empty character class is supported in many (but not all) PCRE-like
>> regex implementations.

Actually, now I can't think of a language other than ECMAScript that
supports empty classes, so "many implementations" was probably wrong.

- stefan

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

ScreenName validation "Mel Smith" <med_cutout_syntel@aol.com> - 2013-01-08 10:44 -0700
  Re: ScreenName validation Scott Sauyet <scott.sauyet@gmail.com> - 2013-01-08 11:02 -0800
    Re: ScreenName validation "Mel Smith" <med_cutout_syntel@aol.com> - 2013-01-08 13:05 -0700
    Re: ScreenName validation Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-01-11 01:28 +0100
      Re: ScreenName validation Jeff North <jnorthau@yahoo.com.au> - 2013-01-11 12:23 +1100
        Re: ScreenName validation Stefan Weiss <krewecherl@gmail.com> - 2013-01-11 03:38 +0100
        Re: ScreenName validation Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-01-11 20:35 +0100
          Re: ScreenName validation Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-01-11 21:22 +0100
            Re: ScreenName validation Stefan Weiss <krewecherl@gmail.com> - 2013-01-11 22:09 +0100
              Re: ScreenName validation Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-01-11 23:23 +0100
                Re: ScreenName validation Stefan Weiss <krewecherl@gmail.com> - 2013-01-12 00:26 +0100
                Re: ScreenName validation Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-01-12 00:54 +0100
              Re: ScreenName validation Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-01-12 00:22 +0100
          Re: ScreenName validation Scott Sauyet <scott.sauyet@gmail.com> - 2013-01-11 13:29 -0800
            Re: ScreenName validation Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-01-12 02:31 +0100

csiph-web