Regular Expressions Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Williard

    Regular Expressions Help

    I am trying to break down the results of Request.ServerV ariables("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.

    --

    Thank You,
    Jason Williard


  • Allan

    #2
    RE: Regular Expressions Help

    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.Visua lBasic.Right(st r, x + 1)
    Exit For
    End If
    Next

    response.write( str1)


    "Jason Williard" wrote:
    [color=blue]
    > I am trying to break down the results of Request.ServerV ariables("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.
    >
    > --
    >
    > Thank You,
    > Jason Williard
    >
    >
    >[/color]

    Comment

    • Jason Williard

      #3
      Re: Regular Expressions Help

      That resulted in a blank page :-(

      Any other ideas?

      --

      Thank You,
      Jason Williard
      Client Services
      PCSafe, Inc.


      "Allan" <Allan@discussi ons.microsoft.c om> wrote in message
      news:A122ADFB-6900-4F35-8EF0-CAB25245D35D@mi crosoft.com...[color=blue]
      > 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.Visua lBasic.Right(st r, x + 1)
      > Exit For
      > End If
      > Next
      >
      > response.write( str1)
      >
      >
      > "Jason Williard" wrote:
      >[color=green]
      >> I am trying to break down the results of Request.ServerV ariables("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.
      >>
      >> --
      >>
      >> Thank You,
      >> Jason Williard
      >>
      >>
      >>[/color][/color]


      Comment

      • Greg Burns

        #4
        Re: Regular Expressions Help

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

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

        s = "test.aspx"

        Greg


        "Jason Williard" <jasondubya@gma il.com> wrote in message
        news:ZZhbd.1756 71$wV.43073@att bi_s54...[color=blue]
        >I am trying to break down the results of Request.ServerV ariables("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.
        >
        > --
        >
        > Thank You,
        > Jason Williard
        >
        >[/color]


        Comment

        • Jason Williard

          #5
          Re: Regular Expressions Help

          Perfect! Thank you very much.

          --

          Thank You,
          Jason Williard


          "Greg Burns" <greg_burns@DON T_SPAM_ME_hotma il.com> wrote in message
          news:eenM3dXsEH A.376@TK2MSFTNG P09.phx.gbl...[color=blue]
          > Not its intended purpose, but if it works...
          >
          > Dim s As String = System.IO.Path. GetFileName("/lang/de/test.aspx")
          >
          > s = "test.aspx"
          >
          > Greg
          >
          >
          > "Jason Williard" <jasondubya@gma il.com> wrote in message
          > news:ZZhbd.1756 71$wV.43073@att bi_s54...[color=green]
          >>I am trying to break down the results of Request.ServerV ariables("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.
          >>
          >> --
          >>
          >> Thank You,
          >> Jason Williard
          >>
          >>[/color]
          >
          >[/color]


          Comment

          Working...