Jump to content

special search string question


Recommended Posts

Hi,

I've try different way to do this (stringregex seems the solution but can't find how) but still no solution :

let's say I have a string "word1_word2"

I have a search input to search in thousands of strings, and I would like to search for "word1 word2" and find "word1_word2"

This behavior would work for " ", "_", "-", both in search and in the string.

Any idea ?

I've tried to stringsplit and then add some "(.*?)" in a new string, and regex search but doesn't work.

Global $search = "word1 word2"
Global $chaine = "bbbword1_word2bbb"

    $searcharray = StringSplit($Search," _-",0)
    If @error <> 1 Then
        $newsearch = ""
        For $i = 1 to $searcharray[0]
            $newsearch &= $searcharray[$i]&"(.*?)"
        Next
        $newsearch = "(.*?)" & $newsearch
        ConsoleWrite(@CR&$newsearch)
    EndIf

    Local $j = 0
    For $t = 1 to $searcharray[0]
        ConsoleWrite(@CR&$searcharray[$t])
        If StringRegExp($chaine, $newsearch, 0) Then
            $j += 1
            ConsoleWrite(@CR&"found one occurence!"&@CR)
        EndIf
    Next
Edited by kiboost

Win7 pro x64. scripts compiled to x64. - Autoit v3.3.6.1 | Scite 1.79

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