Jump to content

Stringregexp using an array.


Recommended Posts

can Stringregexp be used to search an array... like

dim $myarray[51]
for $c=1 to 50
$myarray[$c]=random(1,50,1)
next
$str=Stringregexp($myarray, '25',3)

or do i have to cycle through the array...

for $c=1 to 50
$str=Stringregexp($myarray[$c], '25',3)
next
Link to comment
Share on other sites

You might be able to work out a method based on this example

;
#include <Array.au3>

Local $aArray[50]
For $i = 0 To Ubound($aArray) -1
   $aArray[$i] = ""
   For $j = 1 To 3;; Generate 3 letters for each elelment
      $aArray[$i] &= Chr(Random(97, 122, 1))
   Next
Next
_ArrayDisplay($aArray, "Starting Array")
$sStr = _ArrayToString($aArray);; Create a string from the array
$sRegEx = "(?i)\|?(\w*n\w*)\|?"
$aRegExp = StringRegExp($sStr, $sRegEx, 3);;  Find the combinations that contain the letter "n"
_ArrayDisplay($aRegExp, "RegEx Array")
;

EDIT Whoa up here. In your example you could have used _ArrayFindAll($myArray, 25, 1)

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thanks guys...

i think _ArrayToString() would be better.... as (not mentioned) the string i would need to search for would be "M6 Txxx" where xxx is a 3 digit number.

so

$lines=_ArrayToString($lines,@cr)
$reg=StringRegExp($lines,'\bm6\b.\bt\d*',3)

thanks again both

Edited by Aceguy
Link to comment
Share on other sites

_ArrayFindAll($myArray, "M6 T", 1, 0, 0, 1)

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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