For example, in "http://pear.nadd.tron.com/engg/resources/dwglogs/sum/sumpdf/joesl.pdf", I want to get just "resources/dwglogs/sum/sumpdf/joesl.pdf". The first part is always one of two ways depending on whether the url has "http" or "https", and that is always followed by "://pear.nadd.tron.com/engg/". I want everything after that. I can't see a way to extract the last part of the url I want with SubString and/or IndexOf, so I tried using regular expressions. However, I can't get the example in the Microsoft help file to work (http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpguide/html/cpconexampleextractingurlinformation.asp).
In the example below, I would want the function to return "resources/dwglogs/sum/sumpdf/joesl.pdf". Can you spot where I'm missing it Thanks!
Function Extension(ByVal Url As String) As String
Dim r As New Regex("^(http
Return r.Match(url).Result("${port}")
End Function

Can't get Microsoft Regular Expression to work
David Joyce
Again, thank you!
UPDATE 7/21/06: I just went to use this and realized I missed something. The code above will build the regEx, but I still need to get the value. I get the value through adding the Return in a function:
Function regexExtension(ByVal Url As String) As String
Dim r As New Regex("^(http
Return r.Match(Url).Result("${proto}")
End Function
It looks like "proto" is just a place holder for the value. I tried "crap" and that worked fine too.
R.Tutus
' Imports System.Text.RegularExpressions
' Regular expression built for Visual Basic on: Wed, Jul 19, 2006, 12:46:50 PM
' Using Expresso Version: 2.1.2150, http://www.ultrapico.com
'
' A description of the regular expression:
'
' [Protocol]: A named capture group. [\w+]
' Alphanumeric, one or more repetitions
' :\/\/
' :
' /
' /
' [Domain]: A named capture group. [[\w.]+\/ ]
' [\w.]+\/
' Any character in this class: [\w.], one or more repetitions
' /, zero or one repetitions
' [Rest]: A named capture group. [.*]
' Any character, any number of repetitions
'
'
Public Dim MyRegex as Regex = New Regex( _
"( <Protocol>\w+):\/\/( <Domain>[\w.]+\/ )( <Rest>.*)", _
RegexOptions.IgnoreCase _
Or RegexOptions.CultureInvariant _
Or RegexOptions.IgnorePatternWhitespace _
Or RegexOptions.Compiled _
)