|
From: Robin B. <ro...@kn...> - 2001-09-18 18:02:31
|
On Tuesday 18 September 2001 19:27, Antoine Quint wrote:
> This one might be solved by either of you (now that Stephane and Julien
> have joined).
Welcome ! Who else is here now ?
> I'm trying to split this string: "rgb(255,0,0)" into an array [255,0,0]
>
> I'm using EcmaScript with the Adobe SVG Viewer 3.0 scripting engine
> "split(/\D+/)" to split that string, but the array returned is
> [,255,0,0,] !!!
>
> IE 6.0 does the split as I expect it...
>
> But which split implementation is the correct one?
If I can read E262 correctly, ASV's implementation is the correct one (you
might want to check this with Peter on svg-dev). Of course, E262 is a stupid
standard and a little more dwimity would be nice but this is no reason for
IE6 to break the standard.
Suggested workaround:
/* this is totally untested, but it would be great if it worked */
function isvgNonNumericSplit () {
var preClean = new Regexp('^\D+');
var postClean = new Regexp('\D+$');
this.replace(preClean, '');
this.replace(postClean, '');
return this.split('\D+');
}
// add to the interface
String.prototype.isvgNonNumericSplit = isvgNonNumericSplit;
Of course, chances are that may not work. If so then we're left with the old:
function isvgNonNumericSplit (str) {
var preClean = new Regexp('^\D+');
var postClean = new Regexp('\D+$');
str.replace(preClean, '');
str.replace(postClean, '');
return str.split('\D+');
}
Which looks very similar, except that the former can be called directly on
the string as in mystring.isvgNonNumericSplit() where the latter can only be
called as isvgNonNumericSplit(mystring). If possible I think we should use
(everywhere) the former.
Has anyone figured out how inheritance works in E262 ? Or if it's only
possible ?
--
_______________________________________________________________________
Robin Berjon <ro...@kn...> -- CTO
k n o w s c a p e : // venture knowledge agency www.knowscape.com
-----------------------------------------------------------------------
An eye for an eye will make the whole world blind. -- Mahatma Gandhi
|