[kupu-dev] Kupu and Safari

Duncan Booth duncan.booth at suttoncourtenay.org.uk
Wed Aug 15 20:30:10 CEST 2007


Johnny deBris <johnny at debris.demon.nl> wrote:

> Duncan Booth wrote:
>> 
>> String.prototype.strip = function() {
>>     var stripspace = /^\s*([\s\S]*?)\s*$/;
>>     return stripspace.exec(this)[1];
>> };
>>
> 
> I'm a bit confused here... I would think that:
> 
> /^\s*(.*?)\s*$/
> 
> would have the same result as the current regexp, but this turns out not
> to be true for some reason.

A dot won't match a newline.

> However, since I assume that [\s\S] should
> match any character, and that \u2026 breaks on the \S, perhaps something
> like:
> 
> /\s*([\d\D]*?)\s*$/
> 
> might work?

That might work.

> Just a wild guess... If not, then perhaps:
> 
> /\s*([\s\S\u2026]*?)\s*$/
> 
That won't work: it seems to be a bunch of unicode characters that are 
missing from \S as a character class and nobody knows exactly which ones.

The problem though is that I don't want to have to program in 'a subset of 
those regular expressions which Safari can be bothered to get right', I'd 
much rather they just fixed the bugs.



More information about the kupu-dev mailing list