文本處理 (Text Processing) 服務
*******************************

本章節介紹的模組 (module) 提供了廣泛的字串操作與其他文本處理服務。

在 二進位資料服務 下所描述的 "codecs" 模組也與文本處理高度相關。另外也
請參閱在 Text Sequence Type --- str 中所描述的 Python 內建字串型別。

* "string" --- 常見的字串操作

  * 字串常數

    * "ascii_letters"

    * "ascii_lowercase"

    * "ascii_uppercase"

    * "digits"

    * "hexdigits"

    * "octdigits"

    * "punctuation"

    * "printable"

    * "whitespace"

  * 自訂字串格式

    * "Formatter"

      * "format()"

      * "vformat()"

      * "parse()"

      * "get_field()"

      * "get_value()"

      * "check_unused_args()"

      * "format_field()"

      * "convert_field()"

  * 格式化文字語法

    * 格式規格 (Format Specification) 迷你語言

    * 格式範例

  * 模板字串

    * "Template"

      * "substitute()"

      * "safe_substitute()"

      * "is_valid()"

      * "get_identifiers()"

      * "template"

  * 輔助函式

    * "capwords()"

* "re" --- 正規表示式 (regular expression) 操作

  * 正規表示式語法

  * 模組內容

    * 旗標

      * "RegexFlag"

      * "A"

      * "ASCII"

      * "DEBUG"

      * "I"

      * "IGNORECASE"

      * "L"

      * "LOCALE"

      * "M"

      * "MULTILINE"

      * "NOFLAG"

      * "S"

      * "DOTALL"

      * "U"

      * "UNICODE"

      * "X"

      * "VERBOSE"

    * Functions

      * "compile()"

      * "search()"

      * "match()"

      * "fullmatch()"

      * "split()"

      * "findall()"

      * "finditer()"

      * "sub()"

      * "subn()"

      * "escape()"

      * "purge()"

    * 例外

      * "PatternError"

        * "msg"

        * "pattern"

        * "pos"

        * "lineno"

        * "colno"

  * Regular Expression Objects

    * "Pattern"

    * "search()"

    * "match()"

    * "fullmatch()"

    * "split()"

    * "findall()"

    * "finditer()"

    * "sub()"

    * "subn()"

    * "flags"

    * "groups"

    * "groupindex"

    * "pattern"

  * Match Objects

    * "Match"

    * "expand()"

    * "group()"

    * "__getitem__()"

    * "groups()"

    * "groupdict()"

    * "start()"

    * "end()"

    * "span()"

    * "pos"

    * "endpos"

    * "lastindex"

    * "lastgroup"

    * "re"

    * "string"

  * Regular Expression Examples

    * Checking for a Pair

    * 模擬 scanf()

    * search() vs. match()

    * Making a Phonebook

    * Text Munging

    * Finding all Adverbs

    * Finding all Adverbs and their Positions

    * Raw String Notation

    * Writing a Tokenizer

* "difflib" --- 計算差異的輔助工具

  * "Differ"

  * "HtmlDiff"

    * "__init__()"

    * "make_file()"

    * "make_table()"

  * "context_diff()"

  * "get_close_matches()"

  * "ndiff()"

  * "restore()"

  * "unified_diff()"

  * "diff_bytes()"

  * "IS_LINE_JUNK()"

  * "IS_CHARACTER_JUNK()"

  * SequenceMatcher 物件

    * "SequenceMatcher"

      * "set_seqs()"

      * "set_seq1()"

      * "set_seq2()"

      * "find_longest_match()"

      * "get_matching_blocks()"

      * "get_opcodes()"

      * "get_grouped_opcodes()"

      * "ratio()"

      * "quick_ratio()"

      * "real_quick_ratio()"

  * SequenceMatcher 範例

  * Differ Objects

    * "compare()"

  * Differ Example

  * A command-line interface to difflib

  * ndiff 範例：

* "textwrap" --- 文字包裝與填充

  * "wrap()"

  * "fill()"

  * "shorten()"

  * "dedent()"

  * "indent()"

  * "TextWrapper"

    * "width"

    * "expand_tabs"

    * "tabsize"

    * "replace_whitespace"

    * "drop_whitespace"

    * "initial_indent"

    * "subsequent_indent"

    * "fix_sentence_endings"

    * "break_long_words"

    * "break_on_hyphens"

    * "max_lines"

    * "placeholder"

    * "wrap()"

    * "fill()"

* "unicodedata" --- Unicode 資料庫

  * "lookup()"

  * "name()"

  * "decimal()"

  * "digit()"

  * "numeric()"

  * "category()"

  * "bidirectional()"

  * "combining()"

  * "east_asian_width()"

  * "mirrored()"

  * "decomposition()"

  * "normalize()"

  * "is_normalized()"

  * "unidata_version"

  * "ucd_3_2_0"

* "stringprep" --- 網際網路字串準備

  * "in_table_a1()"

  * "in_table_b1()"

  * "map_table_b2()"

  * "map_table_b3()"

  * "in_table_c11()"

  * "in_table_c12()"

  * "in_table_c11_c12()"

  * "in_table_c21()"

  * "in_table_c22()"

  * "in_table_c21_c22()"

  * "in_table_c3()"

  * "in_table_c4()"

  * "in_table_c5()"

  * "in_table_c6()"

  * "in_table_c7()"

  * "in_table_c8()"

  * "in_table_c9()"

  * "in_table_d1()"

  * "in_table_d2()"

* "readline" --- GNU readline 介面

  * "backend"

  * Init file

    * "parse_and_bind()"

    * "read_init_file()"

  * Line buffer

    * "get_line_buffer()"

    * "insert_text()"

    * "redisplay()"

  * History file

    * "read_history_file()"

    * "write_history_file()"

    * "append_history_file()"

    * "get_history_length()"

    * "set_history_length()"

  * History list

    * "clear_history()"

    * "get_current_history_length()"

    * "get_history_item()"

    * "remove_history_item()"

    * "replace_history_item()"

    * "add_history()"

    * "set_auto_history()"

  * Startup hooks

    * "set_startup_hook()"

    * "set_pre_input_hook()"

  * Completion

    * "set_completer()"

    * "get_completer()"

    * "get_completion_type()"

    * "get_begidx()"

    * "get_endidx()"

    * "set_completer_delims()"

    * "get_completer_delims()"

    * "set_completion_display_matches_hook()"

  * 範例

* "rlcompleter" --- GNU readline 的補全函式

  * "Completer"

    * "complete()"
