Kudos to you!!! You get my ++ any day... This is exactly the solution we've needed, and it was such a simple regex... I don't know why I didn't think of it.
For anyone that's interested, here's the new JavaScript code:
<SCRIPT LANGUAGE="JavaScript">
function ParseStringRegExp (strSource) {
// Split the modified string by spaces or quoted strings.
var aryOutput = strSource.match (/"[^"]*"|\S+/g);
return (aryOutput);
}
</SCRIPT>
No extra arrays needed, and the function is basically a one liner... The VB implementation is just as simple, a single Regex, but of course, we have to iterate through the Matches collection and stored each value into an array for the return value. If anyone wants to see how ugly Regexes are in VBScript, here you are:
<%
Function ParseStringRegExp (strSource)
Dim objRegex
Dim colMatches
Dim objMatch
Set objRegex = New RegExp ' Create a regular expression
+object.
objRegex.Pattern = """[^""]*""|\S+" ' Set pattern.
objRegex.Global = True ' Set global applicabi
+lity.
Set colMatches = objRegex.Execute(strSource) ' Execute search.
Dim aryOutput()
ReDim aryOutput(colMatches.Count - 1) ' Prepare the output a
+rray.
Dim lngMatchCounter
' Grab the colMatches collection and store each value into an array.
lngMatchCounter = 0
For Each objMatch In colMatches
aryOutput(lngMatchCounter) = objMatch.Value
lngMatchCounter = lngMatchCounter + 1
Next
ParseStringRegExp = aryOutput
End Function
%>
|