Fraser Posted December 19, 2013 Share Posted December 19, 2013 (edited) Good evening, To start, sorry if this has been posted/asked before have been searching for an answer for months now. I have created a number/letter string generator for work (some call it a password generator but it’s much more than that ), currently I have a few IF statement that filter for bad letter formats i.e. If StringRegExp($string, "c**k", 0) = 1 then generate() ElseIf StringRegExp($string, "d**k", 0) = 1 then generate() else guictrlsetdata($label1, $string) endif My question is, is there any way to combine multiple search criteria in one IF statement? Thank you. Fraser Edited December 19, 2013 by Fraser Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 19, 2013 Moderators Share Posted December 19, 2013 Strictly in an If statement, you would have to use Or or And If $x = 0 Or $x = 1 Then ; EndIf If $x = 0 And $y = 1 Then ; EndIf "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Fraser Posted December 19, 2013 Author Share Posted December 19, 2013 YaY this worked many thanks! $letters = "c**kt**tf**kd**kYaYdamnworked" If StringRegExp($letters, "women", 0) = 1 or StringRegexp($letters, "man", 0) = 1 or StringRegExp($letters, "worked", 0) Then MsgBox(0, "", "worked found") Else MsgBox(0, "", "Not Found") EndIf Link to comment Share on other sites More sharing options...
mikell Posted December 19, 2013 Share Posted December 19, 2013 Better use the StringRegExp properties If StringRegExp($letters, "women|man|worked") Then ... Link to comment Share on other sites More sharing options...
Fraser Posted December 19, 2013 Author Share Posted December 19, 2013 (edited) I tried that one but unfortunately it doesn't work. Tried this ElseIf StringRegExp($Letters, '[a-z] | \d | [A-Z]', 0) = 1 Then but this didn't work, so tried the below and it works a treat ElseIf StringRegExp($Letters, '[a-z]', 0) = 1 And StringRegExp($Letters, "\d", 0) = 1 And StringRegExp($Letters, '[A-Z]', 0) = 1 Then So look like I will have to stick with this, all though it means the statement is going to be massive! Edited December 19, 2013 by Fraser Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 19, 2013 Moderators Share Posted December 19, 2013 This may not be so in your case, just throwing out there that sometimes, depending on what you're searching for, it is easier to go with what is not than tons of Ifs. If Not $x = 1 Then ExitLoop Else ;Do stuff EndIf "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Malkey Posted December 20, 2013 Share Posted December 20, 2013 I tried that one but unfortunately it doesn't work. Tried this ElseIf StringRegExp($Letters, '[a-z] | \d | [A-Z]', 0) = 1 Then but this didn't work, so tried the below and it works a treat ElseIf StringRegExp($Letters, '[a-z]', 0) = 1 And StringRegExp($Letters, "\d", 0) = 1 And StringRegExp($Letters, '[A-Z]', 0) = 1 Then So look like I will have to stick with this, all though it means the statement is going to be massive! If you really need to put spaces in the regular expression pattern that you do not want matched in the test string, you can add the option, "(?x)" to the RegExp pattern. By default, whitespaces match themselves in RegExp patterns. If StringRegExp("TestString", '(?x)[a-z] | \d | [A-Z]') Then ConsoleWrite("Passed" & @LF) Link to comment Share on other sites More sharing options...
jchd Posted December 20, 2013 Share Posted December 20, 2013 Also, the all-in-one regexp requires the subject to contain a lowercase OR a digit OR an uppercase. The second version requires the subject to contain a lowercase AND a digit AND an uppercase This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
mikell Posted December 20, 2013 Share Posted December 20, 2013 $res = StringRegExp("TestString2", '(?i)[a-z\d]', 3) If IsArray($res) Then ConsoleWrite("Number of matches : " & UBound($res) & @LF) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now