Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/regex/match results"

From cppreference.com
< cpp‎ | regex
m (Text replace - "/sidebar" to "/navbar")
m (fmt)
 
(24 intermediate revisions by 9 users not shown)
Line 1: Line 1:
 
{{cpp/title|match_results}}
 
{{cpp/title|match_results}}
 
{{cpp/regex/match_results/navbar}}
 
{{cpp/regex/match_results/navbar}}
{{ddcl | header=regex | notes={{mark since c++11}} | 1=
+
{{
 +
header|
 +
{{sincec++11|1=
 
template<
 
template<
     class BidirectionalIterator,
+
     class ,
     class Allocator = std::allocator<std::sub_match<BidirectionalIterator>>
+
     class = std::allocator<std::sub_match<>>
 
> class match_results;
 
> class match_results;
 
}}
 
}}
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
The class template {{c|std::match_results}} holds a collection of character sequences that represent the result of a regular expression match.
+
The class template {{|std::match_results}} holds a collection of character sequences that represent the result of a regular expression match.
  
This is a specialized allocator-aware container. It can only be default created or modified by passing to the {{c|std::regex_search()}} or {{c|std::regex_match()}} algorithms.
+
This is a specialized allocator-aware container. It can only be default createdor modified by {{|std::regex_search}} or {{|std::regex_match}}.
  
The first sub_match (index 0) contained in a match_result always represents the full match within a target sequence made by a regex, and subsequent sub_matches represent sub-expression matches corresponding in sequence to the left parenthesis delimiting the sub-expression in the regex.
+
The first sub_match(index 0) contained in a match_resultalways represents the full match within a target sequence made by a regex, and subsequent represent sub-expression matches corresponding in sequence to the left parenthesis delimiting the sub-expression in the regex.
  
 +
 +
 +
 +
 +
 +
 +
 +
 +
 
Several specializations for common character sequence types are provided:  
 
Several specializations for common character sequence types are provided:  
  
{{dcl list begin}}
+
{{begin}}
{{dcl list header | regex}}
+
{{header|regex}}
{{dcl list hitem | Type | Definition}}
+
{{hitem|Type|Definition}}
{{dcl list item | {{tt|cmatch}} | {{c|match_results<const char*>}}}}
+
{{|{{tt|cmatch}}|{{c|match_results<const char*>}}}}
{{dcl list item | {{tt|wcmatch}} | {{c|match_results<const wchar_t*>}}}}
+
{{|{{tt|wcmatch}}|{{c|match_results<const wchar_t*>}}}}
{{dcl list item | {{tt|smatch}} | {{c|match_results<std::string::const_iterator>}}}}
+
{{|{{tt|smatch}}|{{c|match_results<std::string::const_iterator>}}}}
{{dcl list item | {{tt|wsmatch}} | {{c|match_results<std::wstring::const_iterator>}}}}
+
{{|{{tt|wsmatch}}|{{c|
{{dcl list end}}
+
 +
 +
 +
match_results<std::wstring::const_iterator>}}}}
 +
{{end}}
  
 
===Member types===
 
===Member types===
{{dcl list begin}}
+
{{begin}}
{{dcl list hitem | Member type | Definition}}
+
{{hitem|Member type|Definition}}
{{dcl list item | {{tt|allocator_type}} | {{c|Allocator}}}}
+
{{|{{tt|allocator_type}}|{{|Allocator}}}}
{{dcl list item | {{tt|value_type}} | {{c|std::sub_match<BidirectionalIterator>}}}}
+
{{|{{tt|value_type}}|{{c|std::sub_match<>}}}}
{{dcl list item | {{tt|const_reference}} | {{c|const value_type&}}}}
+
{{|{{tt|const_reference}}|{{c|const value_type&}}}}
{{dcl list item | {{tt|reference}} | {{c|const_reference}}}}
+
{{|{{tt|reference}}|{{|}}}}
{{dcl list item | {{tt|const_iterator}} | ''implementation defined'' (depends on the underlying container)}}
+
{{|{{tt|const_iterator}}|''implementationdefined'' (depends on the underlying container)}}
{{dcl list item | {{tt|iterator}} | {{c|const_iterator}}}}
+
{{|{{tt|iterator}}|{{|const_iterator}}}}
{{dcl list item | {{tt|difference_type}} | {{c|std::iterator_traits<BidirectionalIterator>::difference_type}}}}
+
{{|{{tt|difference_type}}|{{c|std::iterator_traits<>::difference_type}}}}
{{dcl list item | {{tt|size_type}} | {{c|std::allocator_traits<Allocator>::size_type}}}}
+
{{|{{tt|size_type}}|{{c|std::allocator_traits<>::size_type}}}}
{{dcl list item | {{tt|char_type}} | {{c|std::iterator_traits<BidirectionalIterator>::value_type}}}}
+
{{|{{tt|char_type}}|{{c|std::iterator_traits<>::value_type}}}}
{{dcl list item | {{tt|string_type}} | {{c|std::basic_string<char_type>}}}}
+
{{|{{tt|string_type}}|{{c|std::basic_string<char_type>}}}}
{{dcl list end}}
+
{{end}}
  
 
===Member functions===
 
===Member functions===
{{dcl list begin}}
+
{{begin}}
{{dcl list template | cpp/regex/match_results/dcl list constructor}}
+
{{|cpp/regex/match_results/constructor}}
{{dcl list template | cpp/regex/match_results/dcl list destructor}}
+
{{|cpp/regex/match_results/destructor}}
{{dcl list template | cpp/regex/match_results/dcl list operator{{=}}}}
+
{{|cpp/regex/match_results/operator{{=}}}}
{{dcl list template | cpp/regex/match_results/dcl list get_allocator}}
+
{{|cpp/regex/match_results/get_allocator}}
  
{{dcl list h2 | State}}
+
{{h2|State}}
{{dcl list mem fun | cpp/regex/match_results/ready | }}
+
{{mem fun|cpp/regex/match_results/ready|}}
  
{{dcl list h2 | Size}}
+
{{h2|Size}}
{{dcl list template | cpp/regex/match_results/dcl list empty}}
+
{{|cpp/regex/match_results/empty}}
{{dcl list template | cpp/regex/match_results/dcl list size}}
+
{{|cpp/regex/match_results/size}}
{{dcl list template | cpp/regex/match_results/dcl list max_size}}
+
{{|cpp/regex/match_results/max_size}}
  
{{dcl list h2 | Element access}}
+
{{h2|Element access}}
{{dcl list template | cpp/regex/match_results/dcl list length}}
+
{{|cpp/regex/match_results/length}}
{{dcl list template | cpp/regex/match_results/dcl list position}}
+
{{|cpp/regex/match_results/position}}
{{dcl list template | cpp/regex/match_results/dcl list str}}
+
{{|cpp/regex/match_results/str}}
{{dcl list template | cpp/regex/match_results/dcl list operator_at}}
+
{{|cpp/regex/match_results/operator_at}}
{{dcl list template | cpp/regex/match_results/dcl list prefix}}
+
{{|cpp/regex/match_results/prefix}}
{{dcl list template | cpp/regex/match_results/dcl list suffix}}
+
{{|cpp/regex/match_results/suffix}}
  
{{dcl list h2 | Iterators}}
+
{{h2|Iterators}}
{{dcl list template | cpp/regex/match_results/dcl list begin}}
+
{{|cpp/regex/match_results/begin}}
{{dcl list template | cpp/regex/match_results/dcl list end}}
+
{{|cpp/regex/match_results/end}}
  
{{dcl list h2 | Format}}
+
{{h2|Format}}
{{dcl list template | cpp/regex/match_results/dcl list format}}
+
{{|cpp/regex/match_results/format}}
  
{{dcl list h2 | Modifiers}}
+
{{h2|Modifiers}}
{{dcl list template | cpp/regex/match_results/dcl list swap}}
+
{{|cpp/regex/match_results/swap}}
 
+
{{end}}
{{dcl list end}}
+
  
 
===Non-member functions===
 
===Non-member functions===
{{dcl list begin}}
+
{{begin}}
{{dcl list tfun | cpp/regex/match_results/operator_cmp | title=operator==<br>operator!= | lexicographically compares the values in the two match result }}
+
{{|cpp/regex/match_results/operator_cmp}}
{{dcl list tfun | cpp/regex/match_results/swap2 | title=std::swap{{dcl small|(std::match_results)}} | specializes the {{cpp/ltf|cpp/algorithm/swap}} algorithm| notes={{mark c++11}}}}
+
{{|cpp/regex/match_results/swap2}}
{{dcl list end}}
+
{{}}
 +
 
 +
{{}}

Latest revision as of 07:15, 25 December 2023