Havoc Posted April 1, 2015 Posted April 1, 2015 (edited) Hello, I'm trying to make strings random in url. For example: Url is: http://google.com/?index.php?$variable1=15&variable2=20&variable=30and go on. I need to make them random like some times $variable1=15&variable2=20&variable=30, sometimes $variable1=15, somtimes $variable1=15&variable2=20 Is there any ideas? I have tried with random() but is not that accurate what I needed. Probably is with array or something else. Thank you. Edited April 1, 2015 by Havoc
jguinch Posted April 1, 2015 Posted April 1, 2015 (edited) Something like this ? $sFullURL = "http://google.com/index.php?$variable1=15&variable2=20&variable=30" $sUrlVar = "([&?][^=]+=[^&]*)" $sShortURL = StringRegExpReplace($sFullURL, $sUrlVar & "{" &Random(0, UBound(StringRegExp($sFullURL, $sUrlVar, 3)), 1) & "}$", "") ConsoleWrite($sShortURL) Edited April 1, 2015 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Havoc Posted April 1, 2015 Author Posted April 1, 2015 (edited) Something like this ? $sFullURL = "http://google.com/index.php?$variable1=15&variable2=20&variable=30" $sUrlVar = "([&?][^=]+=[^&]*)" $sShortURL = StringRegExpReplace($sFullURL, $sUrlVar & "{" &Random(0, UBound(StringRegExp($sFullURL, $sUrlVar, 3)), 1) & "}$", "") ConsoleWrite($sShortURL) Yes that's right! I have got one problem, I need to use 6 variables then script will work what I needed. I have 80 variables. I need to get 6 like 1. Example: http://google.com/index.php?$variable1=15&variable2=20&variable3=30$variable4=15&variable5=20&variable6=30 $variable1=15&variable2=20&variable3=30$variable4=15&variable5=20&variable6=30 - should get like 1. Basiclly 6 counts as 1. Edited April 1, 2015 by Havoc
jguinch Posted April 1, 2015 Posted April 1, 2015 Try with $sUrlVar = "(([&?][^=]+=[^&]*){6})" Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Havoc Posted April 1, 2015 Author Posted April 1, 2015 Try with $sUrlVar = "(([&?][^=]+=[^&]*){6})" Hmm. Nothing changes.
jguinch Posted April 1, 2015 Posted April 1, 2015 Show your code. Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Havoc Posted April 1, 2015 Author Posted April 1, 2015 $sFullURL = "http://google.com/index.php?$variable1=15&variable2=20&variable3=30$variable4=15&variable5=20&variable6=30$variable7=15&variable8=20&variable9=30$variable10=15&variable11=20&variable12=30" $sUrlVar = "(([&?][^=]+=[^&]*){6})" $sShortURL = StringRegExpReplace($sFullURL, $sUrlVar & "{" &Random(0, UBound(StringRegExp($sFullURL, $sUrlVar, 3)), 1) & "}$", "") ConsoleWrite($sShortURL)
jguinch Posted April 1, 2015 Posted April 1, 2015 You url contains some & and some $ : is it normal ? If I replace all $ by &, it seems to work : $sFullURL = "http://google.com/index.php?$variable1=15&variable2=20&variable3=30&variable4=15&variable5=20&variable6=30&variable7=15&variable8=20&variable9=30&variable10=15&variable11=20&variable12=30" $sUrlVar = "(([&?][^=]+=[^&]*){6})" For $i = 1 To 100 $sShortURL = StringRegExpReplace($sFullURL, $sUrlVar & "{" &Random(0, UBound(StringRegExp($sFullURL, $sUrlVar, 3)), 1) & "}$", "") ConsoleWrite($sShortURL & @CRLF) Next Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Havoc Posted April 1, 2015 Author Posted April 1, 2015 You url contains some & and some $ : is it normal ? If I replace all $ by &, it seems to work : $sFullURL = "http://google.com/index.php?$variable1=15&variable2=20&variable3=30&variable4=15&variable5=20&variable6=30&variable7=15&variable8=20&variable9=30&variable10=15&variable11=20&variable12=30" $sUrlVar = "(([&?][^=]+=[^&]*){6})" For $i = 1 To 100 $sShortURL = StringRegExpReplace($sFullURL, $sUrlVar & "{" &Random(0, UBound(StringRegExp($sFullURL, $sUrlVar, 3)), 1) & "}$", "") ConsoleWrite($sShortURL & @CRLF) Next Thank you a lot!
Havoc Posted April 1, 2015 Author Posted April 1, 2015 I have got one more question. How to make it now that those variables I can control randomly? Basiclly like I said 6 as 1. But now I need this I can do random them sometimes 6*5,6*9,6*20 and so on. If I make random(1,5) I should get between 1 and 5. So script make no sense for me tried.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now