Regular Expressions Help

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

Guest

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

Jason Williard

That resulted in a blank page :-(

Any other ideas?

--

Thank You,
Jason Williard
Client Services
PCSafe, Inc.
 
G

Greg Burns

Not its intended purpose, but if it works...

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

s = "test.aspx"

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top