My QA Projects

QA Projects I was involded.

View on GitHub

Pattern Matching - Characters

Literal Characters

Escaped Characters

Literal Examples

'Hello!'
'Goodbye\.' # escape the dot
'End of the line\.\n' # escape the dot, white space new line
'\$100\.00' # escape the dollar sign
'24\+36=60' # escape the + sign
'\\t means tab'

Character Classes

Defining Character Classes

Character Classes Examples

[ABCD] # match only A, B, C or D
[aeiou] # match only a,e,i,o,u
[B-E] # match only B, C, D or E
[^B-E] # match anything but B, C, D or E
[a-z0-5] # match letter from a-z(lowercase) or number 0-5.
[^A-z] # match only non alphabet characters

Character Class Matching

screenshots

Character Classes Shorthand

Shorthand Character Classes

Shorthand Equivalent Description
. . match any single character except newline
\w [A-z0-9_] alphanumeric and _
\W [^A-z0-9_] non - alphanumerics
\d [0-9] digits
\D [^0-9] non digits
\s [ \b\f\n\r\t\v] whitespace
\S [^ \b\f\n\r\t\v] non whitespace

Shorthand Examples

Pattern Description
... match any three characters
\d\d match any two digits
\w\w\w match any three alphanumeric characters
\S match a single - non whitespace character
[A-z]\W match one alphabet followed by a non white space
\d\d\D\D match two digits followed by two non-digits
\s\w\s match one alphanumeric characters surrounded by whitespace

Shorthand Matching Examples

Pattern String
[0-9][0-9][0-9] 510
\d\d\d 510
\d\d\d 94704
\d\d\d x300
\d\d\d 42 [no match]