News from MathTran

Just another WordPress.com weblog

JavaScript split problems

with 2 comments

During the development of some string manipulation methods we ran into some problems with the JavaScript implementation of the split method in different browsers when using regular expressions as delimiters. Other people have had this problem before and Steven Levithan has a nice article about the topic including a script which fixes the inconsistencies between the different browsers, and a test page.

We decided not to use his implementation of the split method, because we do not want to rely on third party code which we have to supply with our distribution and which might break with new browser versions coming out. Instead, we will use a work-around only containing JavaScript code which is consistent among different browsers.

Advertisements

Written by mystar22

June 19, 2008 at 6:31 pm

Posted in Uncategorized

2 Responses

Subscribe to comments with RSS.

  1. That’s a very reasonable approach (not relying on features that are not natively consistent cross-browser). However, for the record, there isn’t much potential for my split method to break future browsers unless their spec compliance regresses even further. My split method follows the spec, and doesn’t do any browser sniffing, so I don’t see any real risk there.

    Steve

    June 19, 2008 at 9:50 pm

  2. Hello Steve. Thank you for your putting things straight regarding your split function. The decision was mostly mine, I think. For me one of the key reasons was this: your JavaScript file wrote a new split function AND put it where the built-in split function lives.

    Your new split function does useful stuff, but I’d rather it did not replace the old one, in case something breaks as a result.

    I’m learning that in JavaScript programming one has to make a lot of compromises. Time will tell us, I hope, whether or not we made the right decision. Finally, thank you for the work you’ve done on cross-browser string manipulation. Very useful.

    jonathanfine

    June 20, 2008 at 7:45 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: