[thelist] IE RegExp Assistance
liorean
liorean at gmail.com
Fri Dec 16 16:00:37 CST 2005
On 16/12/05, Lee Kowalkowski <lee.kowalkowski at lycos.com> wrote:
> From: "Peter Leing" <pleing at Cenlar.com>
> I don't think the split function accepts regular expressions, so how are you splitting the string using regular expressions?
String.prototype.split takes a string, or a regex.
His problem is that iew doesn't enter captured matches into the array
as it should.
> Does (\b+) produce more consistent results?
A boundary may never be adjactent to another boundary, so there's no
need to search for one or more. Just search for a word boundary.
'one two three four'.split(/\b/g)
// => ['one',' ','two',' ','three',' ','four']
'one two three four'.split(/(\s+)/g)
// correct handling of captures => ['one',' ','two',' ','three',' ','four']
// incorrect handling of captures => ['one','two','three','four']
--
David "liorean" Andersson
<uri:http://liorean.web-graphics.com/>
More information about the thelist
mailing list