Re: regular expression question
From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 02/25/04
- Next message: Peter Huang: "Re: Need help with regular expression"
- Previous message: tg: "Debugging an app"
- In reply to: Craig Buchanan: "regular expression question"
- Next in thread: Craig Buchanan: "Re: regular expression question"
- Reply: Craig Buchanan: "Re: regular expression question"
- Messages sorted by: [ date ] [ thread ]
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
>
>
- Next message: Peter Huang: "Re: Need help with regular expression"
- Previous message: tg: "Debugging an app"
- In reply to: Craig Buchanan: "regular expression question"
- Next in thread: Craig Buchanan: "Re: regular expression question"
- Reply: Craig Buchanan: "Re: regular expression question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|