Re: regular expression question
From: Craig Buchanan (someone_at_somewhere.com)
Date: 02/25/04
- Next message: Herfried K. Wagner [MVP]: "Re: ghostscript leaves windword processes"
- Previous message: Michael Maes: "Re: MouseUp-Event gets 'lost'"
- In reply to: Jay B. Harlow [MVP - Outlook]: "Re: regular expression question"
- Next in thread: Jay B. Harlow [MVP - Outlook]: "Re: regular expression question"
- Reply: Jay B. Harlow [MVP - Outlook]: "Re: regular expression question"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 25 Feb 2004 07:28:49 -0600
thanks a lot Jay!
how would the pattern need look if the name wasn't "" delimited. for
example, Herman Munster <1313 Mocking Bird Lane> ? Perhaps find the first
space before the <, then take everything up to that?
Craig
"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com> wrote in message
news:%23uKxzZ0%23DHA.3500@tk2msftngp13.phx.gbl...
> 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: Herfried K. Wagner [MVP]: "Re: ghostscript leaves windword processes"
- Previous message: Michael Maes: "Re: MouseUp-Event gets 'lost'"
- In reply to: Jay B. Harlow [MVP - Outlook]: "Re: regular expression question"
- Next in thread: Jay B. Harlow [MVP - Outlook]: "Re: regular expression question"
- Reply: Jay B. Harlow [MVP - Outlook]: "Re: regular expression question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|