IfInString, savedClip, `; Msgbox correct IfInString, savedClip,`n Msgbox correctIs there a way to group 2 needles together and search haystack once for occurrence of any of them?
IfInString:how to search for multiple needles in 1 haystack?
Started by
metalhead
, Aug 06 2012 11:34 AM
5 replies to this topic
#1
metalhead
Posted 06 August 2012 - 11:34 AM
Hey, I have such a code:
#2
metalhead
Posted 06 August 2012 - 11:38 AM
Also, is there a way to "Loop, parse" for `n or `;?
#3
Guests
Posted 06 August 2012 - 11:45 AM
If (InStr(var,"string) or InStr(var,"otherstring"))or
Checks whether a variable's contents match one of the items in a list.
Source: http://www.autohotke...mmands/IfIn.htm
#4
metalhead
Posted 06 August 2012 - 12:17 PM
thanks!
I had errors with IfInStr about illegal character because I forgot to take the needle into quotation marks.
And what about Loop?
I need loop to parse a string, search either for "`;" or for "`n" (in my case I have items separated either with `; or with `n, so they can't be combined in 1 string).
So I could do so:
Edit: just read an article about loop,parse and decided to follow the manual's advice there:
I had errors with IfInStr about illegal character because I forgot to take the needle into quotation marks.
And what about Loop?
I need loop to parse a string, search either for "`;" or for "`n" (in my case I have items separated either with `; or with `n, so they can't be combined in 1 string).
So I could do so:
IfInString, savedClip, `; separator = `; IfInString, savedClip,`n separator = `nIs it possible to do later something like this?
Loop, Parse, savedClip, %separator%
Edit: just read an article about loop,parse and decided to follow the manual's advice there:
StringReplace, savedClip, savedClip, `n, ¢ StringReplace, savedClip, savedClip, `;, ¢ Loop, Parse, savedClip, ¢
#5
Posted 06 August 2012 - 05:28 PM
Here's something you can do:
Delim := ""
If [color=#0000FF]it has `n in it[/color]
Delim .= "`n"
If [color=#0000FF]it has ; in it[/color]
Delim .= ";"
[color=#0000FF]And then use all delimiters stored in Delim as explained here:
http://www.autohotkey.com/docs/commands/LoopParse.htm[/color]
#6
Posted 06 August 2012 - 09:33 PM
if RegExMatch(savedClip,";|`n",delim)




