# Random StringRegExp Question

## Recommended Posts

How do I find a number of variables random

```\$test0 = "yılınız: 0"
\$test1 = "yılınız: 1"
\$testrand = Random(\$test0,\$test1)
\$year = StringRegExp(\$testrand, '(?i)z:\s(\d+)(.*?)', 3)

if not \$year=1 then
Msgbox(0, "Target", "test 0: " & \$year)

Else
Msgbox(0, "Target", "test 1: " & \$year)

EndIf```

##### Share on other sites

hi

i have find multiple problem :

- StringRegExp return a array, so u need use \$aYear

```#include <Array.au3>; for _ArrayDisplay

\$sStart = "yılınız: "
\$iRandom = Random(1950, 2050, 1); return 1950-2050 integer
\$sString = \$sStart & \$iRandom

; Return "(.*?)" in a array
\$aYear = StringRegExp(\$sString, '(?i)z:\s(\d+)(.*?)', \$STR_REGEXPARRAYGLOBALMATCH)

If @error then
Else
Msgbox(0, "\$iRandom=" & \$iRandom, "Year found : " & \$aYear)
EndIf

;_ArrayDisplay(\$aYear); for help to understand```

##### Share on other sites
```\$test0 = "yılınız: 0"
\$test1 = "yılınız: 1"
\$testrand = Random(0, 1 , 1)
\$testrand = eval("test" & \$testrand)
msgbox(0, "Target" , \$testrand)```

```,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)```

##### Share on other sites

Use an array :

```Local \$aTest = ["yılınız: 0", "yılınız: 1"]

\$testrand = \$aTest[ Random(0, UBound(\$aTest) - 1 , 1) ]
\$year = StringRegExp(\$testrand, '\d+\$', 1)
If @error Then Exit MsgBox(16, "", "invalid string")

MsgBox(0, "", \$year)```

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...