On this page
  1. re.PatternError
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

re.PatternError

Prev: re.Pattern | Up: re | Next: re.purge
Rel: re.compile, re.error, re.escape, re.findall
Ref: docs.python.org โ€” re.PatternError
Tags: #public #python3 #stdlib #re


Import

import re
from re import PatternError

Signature & Overview

re.PatternError(msg, pattern=None, pos=None)

Exception raised for invalid regular expressions.

Methods & Attributes

Usage

import re

try:
    re.compile(r"(unclosed")
except re.error as exc:   # re.PatternError is the Python 3.13+ name (aliased to re.error)
    assert "unterminated" in exc.msg

Gotchas

REPL Inspect

from re import PatternError
help(PatternError)

Linked from

Related notes