Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Match dot

. \

import re

cases = [
    "hello!",
    "hello world.",
    "hello. world",
    ".",
]

for case in cases:
    print(case)
    match = re.search(r'.', case)   # Match any character
    if match:
        print(match.group(0))

print("----")

for case in cases:
    print(case)
    match = re.search(r'\.', case)  # Match a dot
    if match:
        print(match.group(0))

print("----")

for case in cases:
    print(case)
    match = re.search(r'[.]', case) # Match a dot
    if match:
        print(match.group(0))