Character classes


We would like to match any string that has any of the #a#, #b#, #c#, #d#, #e#, #f#, #@# or #.#


examples/regex/character_class.py
import re

strings = [
    'abc',
    'text: #q#',
    'str: #a#',
    'text #b# more text',
    '#ab#',
    '#@#',
    '#.#',
    '# #',
    '##'
    '###'
]


for s in strings:
    print('str:  ', s)
    match = re.search(r'#[abcdef@.]#', s)
    if match:
        print('match:', match.group(0))

r'#[abcdef@.]#'
r'#[a-f@.]#'