Boost.Regex John Maddock Copyright © 1998-2010 John Maddock
Total Page:16
File Type:pdf, Size:1020Kb
Boost.Regex John Maddock Copyright © 1998-2010 John Maddock Distributed under the Boost Software License, Version 1.0. (See accompanying ®le LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Table of Contents Con®guration ........................................................................................................................................................ 3 Compiler Setup .............................................................................................................................................. 3 Locale and traits class selection ........................................................................................................................ 3 Linkage Options ............................................................................................................................................ 3 Algorithm Selection ....................................................................................................................................... 4 Algorithm Tuning .......................................................................................................................................... 4 Building and Installing the Library ............................................................................................................................ 5 Introduction and Overview ....................................................................................................................................... 7 Unicode and Boost.Regex ........................................................................................................................................ 9 Understanding Marked Sub-Expressions and Captures ................................................................................................. 10 Partial Matches .................................................................................................................................................... 14 Regular Expression Syntax ..................................................................................................................................... 17 Perl Regular Expression Syntax ...................................................................................................................... 17 POSIX Extended Regular Expression Syntax ..................................................................................................... 29 POSIX Basic Regular Expression Syntax .......................................................................................................... 36 Character Class Names .................................................................................................................................. 40 Character Classes that are Always Supported ............................................................................................. 40 Character classes that are supported by Unicode Regular Expressions ............................................................. 41 Collating Names .......................................................................................................................................... 43 Digraphs ............................................................................................................................................. 43 POSIX Symbolic Names ........................................................................................................................ 43 Named Unicode Characters .................................................................................................................... 46 The Leftmost Longest Rule ............................................................................................................................ 46 Search and Replace Format String Syntax ................................................................................................................. 48 Sed Format String Syntax .............................................................................................................................. 48 Perl Format String Syntax .............................................................................................................................. 48 Boost-Extended Format String Syntax .............................................................................................................. 50 Reference ........................................................................................................................................................... 53 basic_regex ................................................................................................................................................. 53 match_results .............................................................................................................................................. 64 sub_match .................................................................................................................................................. 72 regex_match ................................................................................................................................................ 84 regex_search ............................................................................................................................................... 88 regex_replace .............................................................................................................................................. 91 regex_iterator .............................................................................................................................................. 95 regex_token_iterator .................................................................................................................................... 101 bad_expression ........................................................................................................................................... 109 syntax_option_type ..................................................................................................................................... 110 syntax_option_type Synopsis ................................................................................................................ 110 Overview of syntax_option_type ............................................................................................................ 111 Options for Perl Regular Expressions ..................................................................................................... 111 Options for POSIX Extended Regular Expressions .................................................................................... 113 Options for POSIX Basic Regular Expressions ......................................................................................... 116 Options for Literal Strings .................................................................................................................... 118 1 XML to PDF by RenderX XEP XSL-FO Formatter, visit us at http://www.renderx.com/ Boost.Regex match_¯ag_type ......................................................................................................................................... 118 error_type ................................................................................................................................................. 122 regex_traits ................................................................................................................................................ 123 Interfacing With Non-Standard String Types .................................................................................................... 124 Working With Unicode and ICU String Types .......................................................................................... 124 Introduction to using Regex with ICU ............................................................................................. 124 Unicode regular expression types ................................................................................................... 124 Unicode Regular Expression Algorithms ......................................................................................... 126 Unicode Aware Regex Iterators ...................................................................................................... 127 Using Boost Regex With MFC Strings .................................................................................................... 133 Introduction to Boost.Regex and MFC Strings .................................................................................. 133 Regex Types Used With MFC Strings ............................................................................................. 133 Regular Expression Creation From an MFC String ............................................................................ 133 Overloaded Algorithms For MFC String Types ................................................................................. 134 Iterating Over the Matches Within An MFC String ............................................................................ 136 POSIX Compatible C API©s .......................................................................................................................... 138 Concepts ................................................................................................................................................... 141 charT Requirements ...........................................................................................................................