Jump to content

Help in stringregexreplace please?


Recommended Posts

please, anyone help me?

i trying this 2 hours and nothing x.x

i need to transform this:

http://www.mysite.com/default.asp?my-category

in

http://www.mysite.com/my-category/

i tryed this:

StringRegExpReplace("http://www.mysite.com/default.asp?my-category" , "([^.?]+[^.?/])", "$1$2")

and others, but... nothing x.x

anyone help me please? thanks a lot!

Edit:

i tryed:

StringRegExpReplace("http://www.mysite.com/default.asp?my-category", "(/default\.asp\??)", "/")

and it works

sorry for the post and thanks all =)

Edited by darkshark
Link to comment
Share on other sites

$in = "http://www.mysite.com/default.asp?my-category"
$expected = "http://www.mysite.com/my-category/"

$real = UrlTransform($in)

If $real = $expected Then
    ConsoleWrite("URL transform: Test succesful" & @CRLF)
Else
    ConsoleWrite("! URL transform: Test failed. Expected: " & $expected & " got: " & $real & @CRLF)
EndIf

Func UrlTransform($url)
    Return StringReplace($url, "default.asp?", "") & "/"
EndFunc

Free unit test included.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...