# 6. Text Processing Services

The modules described in this chapter provide a wide range of string manipulation operations and other text processing services.

The `codecs` module described under Binary Data Services is also highly relevant to text processing. In addition, see the documentation for Python’s built-in string type in Text Sequence Type — str.

- 6.1. `string` — Common string operations
  - 6.1.1. String constants
  - 6.1.2. String Formatting
  - 6.1.3. Format String Syntax
    - 6.1.3.1. Format Specification Mini-Language
    - 6.1.3.2. Format examples
  - 6.1.4. Template strings
  - 6.1.5. Helper functions
- 6.2. `re` — Regular expression operations
  - 6.2.1. Regular Expression Syntax
  - 6.2.2. Module Contents
  - 6.2.3. Regular Expression Objects
  - 6.2.4. Match Objects
  - 6.2.5. Regular Expression Examples
    - 6.2.5.1. Checking for a Pair
    - 6.2.5.2. Simulating scanf()
    - 6.2.5.3. search() vs. match()
    - 6.2.5.4. Making a Phonebook
    - 6.2.5.5. Text Munging
    - 6.2.5.6. Finding all Adverbs
    - 6.2.5.7. Finding all Adverbs and their Positions
    - 6.2.5.8. Raw String Notation
    - 6.2.5.9. Writing a Tokenizer
- 6.3. `difflib` — Helpers for computing deltas
  - 6.3.1. SequenceMatcher Objects
  - 6.3.2. SequenceMatcher Examples
  - 6.3.3. Differ Objects
  - 6.3.4. Differ Example
  - 6.3.5. A command-line interface to difflib
- 6.4. `textwrap` — Text wrapping and filling
- 6.5. `unicodedata` — Unicode Database
- 6.6. `stringprep` — Internet String Preparation
- 6.7. `readline` — GNU readline interface
  - 6.7.1. Example
- 6.8. `rlcompleter` — Completion function for GNU readline
  - 6.8.1. Completer Objects