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 %>

In reply to Re: Re: Regex for escaping spaces in strings when there are quotes by Incognito
in thread Regex for escaping spaces in strings when there are quotes by Incognito

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.