An if statement in Python has the following structure.
if "foo" in "bar" : --do something-- elif : --do something-- else : --do something
if "foo" in "bar" : print ("bar contains foo") else : print ("bar does not contain foo")
Following are command if statements.
|Does not equal||
|Greater than or equal to||
|Less than or equal to||
|If file or directory exists||
|If variable contains||tbd|
|If variable does not contain||tbd|
|If array contains||tbd|
|If string begins with||if re.match('^foo', 'bar'):|
|If string does not begin with||tbd|
|If string ends with||tbd|
|If string does not end with||tbd|
The i option can be used to ignore case.
Multiple conditions can be evaluated by separating each condition with and or or.
More precise conditions can be strung together by evaluating certain conditions together. The possible arrangement of evaluations is literally limitless.
Following are commonly used regular expressions.
|Single integer (0 through 9)||
|Single integer followed by anything||[0-9]*|
|Anything followed by a single integer||*[0-9]|
|Single lower case alpha character||[a-z]|
|Single lower case alpha character followed by anything||[a-z]*|
|Anything followed by single lower case alpha character||*[a-z]|
|Single upper case character||[A-Z]|
|Single upper case alpha character followed by anything||[A-Z]*|
|Anything followed by single upper case alpha character||*[A-Z]|
|Single alpha character||[a-zA-Z]|
|Single alpha character followed by anything||[a-zA-Z]*|
|Anything followed by alpha character||*[a-zA-Z]|
|Any alpha-numeric character||[0-9a-zA-Z]|
|Any alpha-numeric character followed by anything||[0-9a-zA-Z]*|
|Anything followed by any alpha-numeric character||*[0-9a-zA-Z]|
|Any single character except new line||.|
|Any single character except new line followed by anything||.*|
|Space, tab, or newline||\s|
|Not a space, tab, or newline||\S|