Pedantically speaking...
Took part in an interesting but highly pedantic discussion about the relative speeds of 4 different ways to remove a trailing comma from a string. It actually started out discussing purely the performance aspect, then drifted into elegance. Of course I came up with the least most efficacious option, but, IMHO the most elegant!! :-D
Anyways, here were the different ways that the group arrived at:
Method One - Simple:
If Right(theString,1) = "," Then theString = Left(theString, Len(theString)-1) End If
Method Two - Array (maybe 20x slower):
temp = Split( list, "," ) ReDim Preserve temp( UBound(temp)-1 ) list = Join( temp, "," )
Method Three - RegEx (maybe 30x slower):
Set re = New RegExp re.Pattern = "\,$" list = re.Replace( list, "" )
Method Four - Switching language contexts (slowest of all):
<% Dim myStrng : myStrng = "the,grand,poobah," myStrng = RemoveTrailingComma( myStrng ) Response.Write myStrng %> <script language="jscript" runat="server"> function RemoveTrailingComma( strng ) { return strng.replace( /\,$/, '') ; } </script>
Oh the fun of it :-) Today I have to read up on creating skins for Windows Media Player 9 for the jukebox app. I've started by reading this nice intro: A simple skin and, of course there's always the Media Player 9 home page: Windows Media Player 9 Series