Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #15993
| From | "Scott Sauyet" <3103invalid@webnews.fastusenet.org> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: regexp help |
| Message-ID | <201209191156343103@webnews.fastusenet.org> (permalink) |
| References | <fqydnZxNJ4Gw59TNnZ2dnUVZ_sidnZ2d@westnet.com.au> <aatr4mFvsbU1@mid.uni-berlin.de> <1492793.DGNhQbDWfW@PointedEars.de> <201209111651133103@webnews.fastusenet.org> <2835510.oF4MCyIXXA@PointedEars.de> |
| Date | 2012-09-19 11:56 +0000 |
Thomas 'PointedEars' Lahn wrote:
> Scott Sauyet wrote:
>> Thomas 'PointedEars' Lahn wrote:
>>> [ ... ]
>>> Which gives me the idea that a Unicode mode for jsx.regexp.RegExp() to
>>> replace \b, \w and \W in addition to or using the already implemented
>>> Unicode character properties (\p{Lu} et al.) would come in handy.
> [ ... ]
>> I haven't looked at the jsx.regexp implementation. �Would this be
>> straightforward to add?
>
> It was not straightforward to implement (character property class
> definitions L, M, N, and Word had to be added, and the character class
> normalizer had to be generalized � so that `[^a\Wb]' is equivalent to `(?:
> [^ab]|[\p{Word}])' *before* escape sequence expansion).
>
> But � as my Twitter followers are already aware � I did it today. �
> Currently, \w and \W only; \b is a bit more tricky.
Yes, I dug around in the implementation a bit this morning, only enough to see
the broad outlines of what you're doing. It looks interesting, and it looks
challenging. And it looks entirely worth doing. I have no idea yet of how well
you've managed to accomplish it. So maybe I shouldn't be as impressed as I am.
:-)
>> [ ... ]
>> Is the notion of what "would reasonably be included [in an expanded `\w`
>> mode]" even coherent?
>
> Yes, the Unicode standard assigns properties to characters, such as Letter
> (L). �I had already created a version of the Unicode Character
> Database (UCD) in ECMAScript (UnicodeData.js), and a parser for the plain-
> text version of the UCD (UnicodeData.txt, which can be freely downloaded
> from unicode.org), to replace escape sequences with character classes.
Ok, that makes sense. I'm clearly going to have to spend more time on this.
>> Obviously you could make whatever call you choose about
>> what to include, but is there an obvious call to make?
>
> Yes, Perl already specifies it, so I followed perlrecharclass(1) (but I
> forgot to include \p{N}; that has been fixed in the meantime).
>
> However, I can see now that it is wrong to call my implementation of \w in
> Unicode mode *PCRE*-conforming, as pcrepattern(1) specifies it differently:
> \w is equivalent to [\p{L}\p{N}_] there, while according to
> perlrecharclass(1) it appears to be [\p{L}\p{M}\p{N}\p{Pc}] in Perl.
>
> I think that Perl's definition is better than PCRE's here [ ... ]
So yes, there are obvious choices, but which of the obvious choices is best is
still up for grabs? :-)
>> [ ... ]
> Please try regexp.js (in fact, please try all of JSX). �Any (constructive)
> feedback (here or elsewhere) is welcome. �(I am still working on anonymous
> SVN read access, and privileged SVN write access, before I will probably
> switch to git in the long term.)
I've been reading from the SVN web front end you supply, and haven't looked for
plain downloads yet.
I mostly have used JSX the way I do several other libraries by regulars here, as
sources of inspiration, sometimes looking to say, "Ah, so that's how Garrett
chooses to do it, and that's how Thomas does it, and that's how David's works.
I've never incorporated any of these libraries as they stand into projects. I'm
not quite sure why except that usually for my own projects, I like to roll my
own code and for work, I'm almost always constrained to use certain libraries.
(You can guess which ones!)
But I will try JSX regexp the next time I need to do something interesting with
regex.
Thank you for your effort with this.
-- Scott
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
regexp help Andrew Poulos <ap_prog@hotmail.com> - 2012-09-07 14:37 +1000
Re: regexp help Jake Jarvis <pig_in_shoes@yahoo.com> - 2012-09-07 10:55 +0200
Re: regexp help Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-07 15:36 +0200
Re: regexp help Andrew Poulos <ap_prog@hotmail.com> - 2012-09-08 10:27 +1000
Re: regexp help Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-08 09:34 +0200
Re: regexp help "Scott Sauyet" <3103invalid@webnews.fastusenet.org> - 2012-09-11 16:51 +0000
Re: regexp help Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-11 22:31 +0200
Re: regexp help "Scott Sauyet" <3103invalid@webnews.fastusenet.org> - 2012-09-19 11:56 +0000
Re: regexp help Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-19 18:51 +0200
Re: regexp help Scott Sauyet <scott.sauyet@gmail.com> - 2012-09-19 12:52 -0700
Re: regexp help Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-20 02:13 +0200
Re: regexp help Scott Sauyet <scott.sauyet@gmail.com> - 2012-09-20 06:51 -0700
Re: regexp help Dr J R Stockton <reply1237@merlyn.demon.co.uk.invalid> - 2012-09-20 20:23 +0100
Re: regexp help "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-09-11 14:55 -0700
csiph-web