Regular Expressions Help

  • Thread starter Thread starter Jason Williard
  • Start date Start date
J

Jason Williard

I am trying to break down the results of Request.ServerVariables("URL") into
just the name of the script. Currently, the output is looking like:

/lang/de/test.aspx

I want to strip the /lang/de/ and keep test.aspx. The /lang/de/ may not
always be there. Sometimes it may just be "/" or there may be more than 2
layers. I'm assuming that there should be an easy way to do this with
regular expressions, but I'm not very good at them. Any assistance would be
greatly appreciated.
 
try this:

Dim str As String = "/lang/en/test.aspx"
Dim str1 As String = ""

Dim x As Integer = 0
For x = Len(str) - 1 To 0
If str.Chars(x) = "/" Then
str1 = Microsoft.VisualBasic.Right(str, x + 1)
Exit For
End If
Next

response.write(str1)
 
That resulted in a blank page :-(

Any other ideas?

--

Thank You,
Jason Williard
Client Services
PCSafe, Inc.
 
Not its intended purpose, but if it works...

Dim s As String = System.IO.Path.GetFileName("/lang/de/test.aspx")

s = "test.aspx"

Greg
 
Back
Top