Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #18075
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.albasani.net!.POSTED!not-for-mail |
|---|---|
| From | Stefan Weiss <krewecherl@gmail.com> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: ScreenName validation |
| Date | Fri, 11 Jan 2013 22:09:44 +0100 |
| Organization | albasani.net |
| Lines | 38 |
| Message-ID | <kcpv2o$epv$1@news.albasani.net> (permalink) |
| References | <al347sFepchU1@mid.individual.net> <53ccd13b-a933-4bbc-ba0a-7061cc9064cd@4g2000yqv.googlegroups.com> <m28v807ec9.fsf@nntp.bednarz.nl> <r1que89eftmfejrieqstmo7bp1ra3e92rv@4ax.com> <m2hamnqzr4.fsf@nntp.bednarz.nl> <m2obgvii6g.fsf@nntp.bednarz.nl> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.albasani.net fsOd2YMfP5DYTJ7zC5FQ7fFcg6naKBnV5C3LKNoBbhx7WCXtE+0tzJwa+cjmSgAQ0mEGg2Gfm9RixfKWCadIsaKQBaEWsZ/KOz4dKm66ymQScGV8bhDIejbnRoEJYkgX |
| NNTP-Posting-Date | Fri, 11 Jan 2013 21:09:44 +0000 (UTC) |
| Injection-Info | news.albasani.net; logging-data="t14VIkK3KoIs1wQL1J6c8ZKAjk+J3QOyVKpU9d2KTp7V8h8C46KScOND1Sv8Hg2nxh+5yYKFU7jdtbksCaOE9ibpG33gJxquBTz22no1Lnkgmfz2Hrpd+2XPGlvE5fb4"; mail-complaints-to="abuse@albasani.net" |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 |
| In-Reply-To | <m2obgvii6g.fsf@nntp.bednarz.nl> |
| Cancel-Lock | sha1:XwE3ll4KDRTNsxd0AGdspUzn2wo= |
| Xref | csiph.com comp.lang.javascript:18075 |
Show key headers only | View raw
On 2013-01-11 21:22, Eric Bednarz wrote:
> Eric Bednarz <bednarz@fahr-zur-hoelle.org> writes:
>
>> The only character that *must* to be escaped in a character class is the
>> escape character itself.
>
> While this is true in most modern regular expression implementations, I
> just realized that it is actually false in ECMAScript, which
> inexplicably features empty character classes, so a closing square
> bracket literal actually has to be escaped.
Could you give an example of when the literal ] character doesn't have
to be escaped in a character class?
The empty character class is supported in many (but not all) PCRE-like
regex implementations. It matches any character that belongs to the set
of no characters - in other words, it will never match. I'm not sure
where that would be useful. The inverse case, [^], matches any
character. It actually has a use, because it also matches newlines
(which are not matched by the "." special character).
In addition to "\", "]", and "-", some languages also require the regex
delimiter to be escaped in regex literals.
/[/]/.test("/") // true in ECMAScript
"/" =~ /[/]/ # syntax error in Perl
/[/]/.match("/") # syntax error in Ruby
preg_match("/[/]/", "/") // syntax error in PHP
ECMAScript is the odd one out here. For that reason, and because it can
mess up syntax highlighting, I'd also escape a slash in a character class.
> Except for JScript < 10. Them damn implementations of. :-)
JScript behaving differently from the rest? Shocking.
- stefan
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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