Re: regular expression question

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

From: Craig Buchanan (someone_at_somewhere.com)
Date: 02/25/04


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



Relevant Pages

  • Re: Regex question
    ... structure of the date you're trying to extract. ... For example, in Regex you can ... pattern that will ensure a valid date within the range allowed by T-SQL ... valid date from a string. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Interaction between two strings
    ... then the string XYZC should give a match. ... > string that is supplied separately from the regex. ... $patterns, you splice them all into one very big $pattern. ... Doing this is immensely faster than iterating through an array or the like: ...
    (comp.lang.perl.misc)
  • str.scan
    ... Regexp or a String). ... added to the result array or passed to the block. ... If the pattern ...
    (comp.lang.ruby)
  • Re: regex
    ... case sensitivity was part of the problem which I fixed with ... In other word I got syntax problem with the month pattern ... >>against the articles and help on regex, I still can't find the mistake I ... >> Public Function regtest(ByVal StringIn As String, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How do I shorten or split this function
    ...    (scan regex string) ... Instead of field-name you mean field-type. ... it doesn't test the string to see if it's of the suitable form for the ... corresponding field of the pattern. ...
    (comp.lang.lisp)