Sign in to follow this  
Followers 0
Fraser

Filter for more than one value in a string!!

9 posts in this topic

#1 ·  Posted (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 :P ), 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 by Fraser

Share this post


Link to post
Share on other sites



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

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Fraser

Share this post


Link to post
Share on other sites

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

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
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
Sign in to follow this  
Followers 0