Jump to content

Searching for a string in any order?


Recommended Posts

Yes, well kind of. Using regexp with "[abc]+" will match b ab bac bbbbbbbbbbbbbbbbbb accc. An exact match with the same number of characters is going to involve some additional steps. Interesting to think about. Regexp might not be the best way to approach this. If you search for anagram you might find some scripts which will help you.

BTW this is the wrong forum. Ask to have this topic moved to Help and Support.

Edited by czardas
Link to comment
Share on other sites

An example.

#include <Array.au3>

Local $sTestString = "1001001101010101011010100"
Local $sString = "101"

;------------ Create Reg Exp Pattern ----------------
Local $aArray = StringSplit($sString, "", 2)
Local $aNewArray = _ArrayPermute($aArray, "")
$aNewArray = _ArrayUnique($aNewArray, 1, 1, 0, 0)
;_ArrayDisplay($aNewArray, "Array Permuted")
Local $sRegExpPattern = "(" & _ArrayToString($aNewArray, "|") & ")"
ConsoleWrite($sRegExpPattern & @LF)
;---------> End of Create Reg Exp Pattern ------------

Local $aResults = StringRegExp($sTestString, $sRegExpPattern, 3)
_ArrayDisplay($aResults)
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...