Regular Expressions

Regular expressions is a concept used to search for patterns in string text.

This is a univerisal concept for any programming language or text editing program.

We're going to learn the concepts while we learn the syntax for python.

The goal of regular expressions is to be able to search for a specific type of text inside of a string. If we have a form on our webpage where we ask for email addresses, can we check whether the inputted string actually follows the form of an email? some letters or numbers or special characters, then an @ sign then some more letters numbers or special characters then a . then a few more letters

    .       - Any Character Except New Line
    \d      - Digit (0-9)
    \D      - Not a Digit (0-9)
    \w      - Word Character (a-z, A-Z, 0-9, _)
    \W      - Not a Word Character
    \s      - Whitespace (space, tab, newline)
    \S      - Not Whitespace (space, tab, newline)

    \b      - Word Boundary
    \B      - Not a Word Boundary
    ^       - Beginning of a String
    $       - End of a String

    []      - Matches Characters in brackets
    [^ ]    - Matches Characters NOT in brackets
    |       - Either Or
    ( )     - Group

    Quantifiers:

    *       - 0 or More
    +       - 1 or More
    ?       - 0 or One
    {3}     - Exact Number
    {3,4}   - Range of Numbers (Minimum, Maximum)

Searching literals

Searching special characters

Word boundary

Character sets

Character groups

Quantifiers

Accessing information in the Match object