Regex Split bug in JScript?

I’ve been messing around with JavaScript quite a bit recently and I came across a ‘bug’ in the Microsoft implementation of the split() method.

Take the following example string (note the two tabs at the end):

var s = “HellotHowtaretyoutt”;

and then run the following to write it out to the screen:

document.writeln(s.split(“t”));

Well that works as expected, and outputs “Hello,How,are,you,,”;

But if you replace the string in the split method with an inline Regex object it fails if run under a Microsoft implementation

document.writeln(s.split(/t/));

This outputs the same as above in Firefox etc, but if run in JScript (i.e. Internet Explorer) you lose all empty elements and get the following: “Hello,How,are,you”. This is really weird, because if you use the string delimiter above it works just fine.

I have managed to find another blog post that tries to fix this problem, but doesn’t say why it happens.

http://blog.stevenlevithan.com/archives/cross-browser-split

To test this online, try going to W3Schools.com.

Helping out on the Wrox forums

Wrox ProfileSince I started working as the technical editor for the XSLT 2.0 and XPath 2.0 reference book I thought I’d try my hand at helping out on the Wrox Programmer to Programmer (P2P for short) forums.

When I first started out I was a ‘Starting Member’ but soon progressed to ‘New Member’.

Not long after that I noticed I’d gone up in status to ‘Junior Member’, which I actually found to be slightly condescending! I’m 33, I’m hardly a junior anything anymore.

Now however I’ve just passed the 200 post mark and I’m now a plain ‘Member’, although I do get 3 funky red stars to my name.

My Wrox Forums profile

I help out mostly on the XSLT forum, but I’ve been straying onto the C# and C# 2005 forums of late too. I find the post volume is about right for me to not get overloaded – compared to the Microsoft Forums where I can barely keep up. Luckily the Microsoft forums has a helpful ‘answered’ feature, so you can easily see which posts still need help.

However for some reason sometimes when I click on the ‘Reply’ button it logs me out – very annoying.

Overall though I find helping out others useful as makes me think about the way I work, plus I try to write my proposed solutions in a way that they should hopefully learn a little without just writing out the answer for them. Its the way I would want to be answered.

Still, the most annoying thing is those questions where the answer is on the first page of the results I find when I search google. Is it just laziness do you think? My typical response to these is now just “Google is your friend”.


Official ASP.NET MVC framework – CTP release in ‘next few weeks’

News about the recently previewed Model-View-Controller framework for ASP.Net is that a first look Community Technology Preview is due out in a few weeks.

It will form part of the ASP.Net Futures release, which is a product I had a quick look at recently, and includes some wonderful stuff on Dynamic Forms.

For an overview of what the ASP.Net MVC will do there is a recording of a presentation Scott Hanselman did recently here, as well as an overview of the framework by Scott Guthrie here (if you’re not subscribed to Scott’s blog yet then why not – he provides some of the most concise yet informationful (is that a word?) blog posts imaginable about ASP.Net and associated technologies).

It seems likely that the next release of the ASP.Net Futures will be released soon after Visual Studio 2008 and .Net Framework 3.5, which are both due out before the end of November, so we shouldn’t have long to wait.

Official ASP.NET MVC framework will have first CTP release in ‘next few weeks’ « codeville

Other MVC frameworks do exist for .Net, such as MonoRail from the Castle Project. I haven’t had a chance to look at this, but it appears to be an attempt at a port of Ruby on Rails like functionality into the .Net environment.

Top 10 things to know about Visual Studio 2008 and .NET Framework 3.5

Top 10 things to know about Visual Studio 2008 and .NET Framework 3.5

Daniel Moth (‘The Moth’) lists 10 very good reasons why I’m looking forward to Visual Studio 2008.

The killer feature for me is still the fact that I can target .Net 2.0, which means I can upgrade straight away from Visual Studio 2005, play with the new features, but still get my day job done.

Implementing extension methods to XSLT in .Net

Most XSLT processors contain methods to call custom methods (known as extension methods) written in your favourite programming language. Java XSLT processors allow you to write them in Java, and the old MSXML processor allowed you to write the in VBScript or Javascript.

The new .Net Framework classes XslTransform (or more recently XslCompiledTransform) allows you to write them in any .Net language.

But how do you implement these? Well there are two methods you can choose from, read more below the break:

Continue reading “Implementing extension methods to XSLT in .Net”

Getting the XmlEnumAttribute value for an Enum field

I recently had to convert an Enum back to its original Xml value so I thought I’d share the little method I wrote with you all incase you wondered how to do it yourself.

Method

Example Enum Class

Example usage

An Enum of TestEnumClass.FirstValue will then return “FirstValue”, while TestEnumClass.ThirdValue will return “The Third one”.

Hope you find that useful.