Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/regex"

From cppreference.com
< cpp
m (desc for the iterators)
(+templates, -comments aboutregex-constants)
Line 12: Line 12:
 
{{dcl list begin}}
 
{{dcl list begin}}
 
{{dcl list template | cpp/regex/dcl list basic_regex }}
 
{{dcl list template | cpp/regex/dcl list basic_regex }}
{{dcl list tclass | cpp/regex/sub_match | identifies a sub match in the analyzed string | notes={{mark c++11}}}}
+
{{dcl list template | cpp/regex/dcl list sub_match }}
 
{{dcl list template | cpp/regex/dcl list match_results }}
 
{{dcl list template | cpp/regex/dcl list match_results }}
 
{{dcl list end}}
 
{{dcl list end}}
Line 21: Line 21:
  
 
{{dcl list begin}}
 
{{dcl list begin}}
{{dcl list tfun | cpp/regex/regex_match | try to match a regular expression with a complete string | notes={{mark c++11}}}}
+
{{dcl list template | cpp/regex/dcl list regex_match }}
{{dcl list tfun | cpp/regex/regex_search | check if a regular expression occurs anywhere within a string | notes={{mark c++11}}}}
+
{{dcl list template | cpp/regex/dcl list regex_search }}
{{dcl list tfun | cpp/regex/regex_replace | replace occurrences of a regular expression with some other text | notes={{mark c++11}}}}
+
{{dcl list template | cpp/regex/dcl list regex_replace }}
 
{{dcl list end}}
 
{{dcl list end}}
  
Line 31: Line 31:
  
 
{{dcl list begin}}
 
{{dcl list begin}}
{{dcl list tclass | cpp/regex/regex_iterator | iterates through regex matches | notes={{mark c++11}}}}
+
{{dcl list template | cpp/regex/dcl list regex_iterator }}
{{dcl list tclass | cpp/regex/regex_token_iterator | iterates through regex submatches | notes={{mark c++11}}}}
+
{{dcl list template | cpp/regex/dcl list regex_token_iterator }}
 
{{dcl list end}}
 
{{dcl list end}}
  
Line 40: Line 40:
  
 
{{dcl list begin}}
 
{{dcl list begin}}
{{dcl list class | cpp/regex/regex_error | | notes={{mark c++11}}}}
+
{{dcl list template | cpp/regex/dcl list regex_error }}
 
{{dcl list end}}
 
{{dcl list end}}
  
Line 48: Line 48:
  
 
{{dcl list begin}}
 
{{dcl list begin}}
{{dcl list tclass | cpp/regex/regex_traits | | notes={{mark c++11}}}}
+
{{dcl list template | cpp/regex/dcl list regex_traits }}
 
{{dcl list end}}
 
{{dcl list end}}
  
Line 59: Line 59:
 
{{dcl list template | cpp/regex/dcl list error_type}}
 
{{dcl list template | cpp/regex/dcl list error_type}}
 
{{dcl list end}}
 
{{dcl list end}}
 
<!--=====regex_constants=====
 
 
The namespace ''std::regex_constants'' holds symbolic constants used by the regular expression library.  These constants are used to modify how regular expressions are created and executed.
 
 
===Contents===
 
 
The namespace provides three types:
 
 
  * [[syntax_option_type]]
 
  * [[match_flag_type]]
 
  * [[error_type]]
 
 
In addition, ''std::regex_constants'' defines several bitwise operators for manipulating each type.
 
 
===Example===
 
 
The ''[[/regex/basic_regex/]]'' defines internal constants that match [[syntax_option_type]] that can be used to change how regular expressions operate.  The following code creates a regular expression for type ''char'' (i.e. ''std::regex'') that is case-insensitive and optimized for match speed):
 
 
<code>
 
std::regex imageRegex(R"(\w+\.((gif)|(png)|(jpg)))",
 
                      std::regex::icase | std::regex::optimize);
 
</code>
 
 
-->
 

Revision as of 07:38, 29 May 2012

Template:cpp/regex/sidebar

The regular expressions library provides a class that represents regular expressions, which are a kind of mini-language used to perform pattern matching within strings.

Also provided in the regular expressions library are utility classes that provide support for various algorithms, iterators, exceptions, and type traits.

Contents

Main classes

These classes encapsulate a regular expression and the results of matching a regular expression within a target sequence of characters.

Template:cpp/regex/dcl list basic regexTemplate:cpp/regex/dcl list sub matchTemplate:cpp/regex/dcl list match results

Algorithms

These functions are used to apply the regular expression encapsulated in a regex to a target sequence of characters..

Template:cpp/regex/dcl list regex matchTemplate:cpp/regex/dcl list regex searchTemplate:cpp/regex/dcl list regex replace

Iterators

The regex iterators are used to traverse the entire set of regular expression matches found within a sequence.

Template:cpp/regex/dcl list regex iteratorTemplate:cpp/regex/dcl list regex token iterator

Exceptions

This class defines the type of objects thrown as exceptions to report errors from the regular expressions library.

Template:cpp/regex/dcl list regex error

Traits

The regex traits class is used to encapsulate the localizable aspects of a regex.

Template:cpp/regex/dcl list regex traits

Constants

Template:cpp/regex/dcl list syntax option typeTemplate:cpp/regex/dcl list match flag typeTemplate:cpp/regex/dcl list error type
Defined in namespace std::regex_constants