Re: regular expression question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 02/25/04


Date: Tue, 24 Feb 2004 20:23:44 -0600

Craig,
> I have a string in the format "name" <address> that i would like to split
> into an array of two values.
You can parse the values, however you will need to manually build the array.

> what does my regex pattern need to be?
You can use the following RegEx to parse the string:

        Dim ex As New Regex("^\""(?<name>.*)\"" \<(?<address>.*)\>$")

        Dim match As Match = ex.Match("""Herman Munster"" <1313 Mocking Bird
Lane>")

        Debug.WriteLine(match.Groups("name"), "name")
        Debug.WriteLine(match.Groups("address"), "address")

> If the regex doesn't
> find occurances of two double quotes and an occurance of < and an
occurance
> of >, will i get a null string array?
You will not have a match, so yes you will have an empty string returned.

> btw, is there a difference between:
>
> dim X() as string and dim X as string() ?
Nothing, they are both an array of Strings, the first is useful when you are
defining a string scalar & array on the same line, while the second is
needed for function & property return values.

    Dim y, x() as String

    Public Function ReturnStringArray() As String()

Hope this helps
Jay

"Craig Buchanan" <someone@somewhere.com> wrote in message
news:e3fJx8x%23DHA.2180@TK2MSFTNGP09.phx.gbl...
> I have a string in the format "name" <address> that i would like to split
> into an array of two values. name should be the first value, address the
> second value. what does my regex pattern need to be? If the regex
doesn't
> find occurances of two double quotes and an occurance of < and an
occurance
> of >, will i get a null string array?
>
> btw, is there a difference between:
>
> dim X() as string
> and
> dim X as string() ?
>
> Thanks,
>
> Craig Buchanan
>
>



Relevant Pages

  • Help in French|Spanish|German translation.
    ... I am also an author of User-defined string functions. ... WORDTRANEX (cSearched, cArExpressionSought | cExpressionSough, ... each string of the array is searched ... If the parameter nArStartOccurrence is -1 or omitted, the replacement starts ...
    (microsoft.public.fox.helpwanted)
  • Re: passing a string to a dll
    ... Joe, I really appreciate you taking the time to demonstrate this. ... sure how I would implement indexing it for random alphanumeric codes. ... I might handle the array. ... I actually have been wondering if I could use a second string ...
    (microsoft.public.vc.mfc)
  • Re: passing a string to a dll
    ... I might handle the array. ... I actually have been wondering if I could use a second string ... look at insertion cost, organization cost, and search cost. ...
    (microsoft.public.vc.mfc)
  • RE: Structure conversion from C++ to VB-2008?
    ... One of the most important structures is AmiVar structure. ... point number, the array of floating point numbers, a string or IDispatch ... Dim 13012679 as Integer ...
    (microsoft.public.dotnet.languages.vb)
  • Structure conversion from C++ to VB-2008?
    ... One of the most important structures is AmiVar structure. ... point number, the array of floating point numbers, a string or IDispatch ... Dim 13012679 as Integer ...
    (microsoft.public.dotnet.languages.vb)