Jump to content

Make a random variables


Recommended Posts

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 by Havoc
Link to comment
Share on other sites

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 by jguinch
Link to comment
Share on other sites

 

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 by Havoc
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

 

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!

Link to comment
Share on other sites

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.

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