Sign in to follow this  
Followers 0
darkshark

Help in stringregexreplace please?

2 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0