Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | regex
m (Text replace - "{{mark c++11 feature}}" to "{{mark since c++11}}")
m (Text replace - "{{cpp|" to "{{c|")
Line 8: Line 8:
 
}}
 
}}
  
The class template {{cpp|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 {{cpp|std::regex_search()}} or {{cpp|std::regex_match()}} algorithms.
+
This is a specialized allocator-aware container.  It can only be default created or modified by passing to the {{|std::regex_search()}} or {{|std::regex_match()}} algorithms.
  
 
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_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.
Line 19: Line 19:
 
{{tdcl list header | regex}}
 
{{tdcl list header | regex}}
 
{{tdcl list hitem | Type | Definition}}
 
{{tdcl list hitem | Type | Definition}}
{{tdcl list item | {{tt|cmatch}} | {{cpp|match_results<const char*>}}}}
+
{{tdcl list item | {{tt|cmatch}} | {{|match_results<const char*>}}}}
{{tdcl list item | {{tt|wcmatch}} | {{cpp|match_results<const wchar_t*>}}}}
+
{{tdcl list item | {{tt|wcmatch}} | {{|match_results<const wchar_t*>}}}}
{{tdcl list item | {{tt|smatch}} | {{cpp|match_results<std::string::const_iterator>}}}}
+
{{tdcl list item | {{tt|smatch}} | {{|match_results<std::string::const_iterator>}}}}
{{tdcl list item | {{tt|wsmatch}} | {{cpp|match_results<std::wstring::const_iterator>}}}}
+
{{tdcl list item | {{tt|wsmatch}} | {{|match_results<std::wstring::const_iterator>}}}}
 
{{tdcl list end}}
 
{{tdcl list end}}
  
Line 28: Line 28:
 
{{tdcl list begin}}
 
{{tdcl list begin}}
 
{{tdcl list hitem | Member type | Definition}}
 
{{tdcl list hitem | Member type | Definition}}
{{tdcl list item | {{tt|allocator_type}} | {{cpp|Allocator}}}}
+
{{tdcl list item | {{tt|allocator_type}} | {{|Allocator}}}}
{{tdcl list item | {{tt|value_type}} | {{cpp|std::sub_match<BidirectionalIterator>}}}}
+
{{tdcl list item | {{tt|value_type}} | {{|std::sub_match<BidirectionalIterator>}}}}
{{tdcl list item | {{tt|const_reference}} | {{cpp|const value_type&}}}}
+
{{tdcl list item | {{tt|const_reference}} | {{|const value_type&}}}}
{{tdcl list item | {{tt|reference}} | {{cpp|const_reference}}}}
+
{{tdcl list item | {{tt|reference}} | {{|const_reference}}}}
 
{{tdcl list item | {{tt|const_iterator}} | ''implementation defined'' (depends on the underlying container)}}
 
{{tdcl list item | {{tt|const_iterator}} | ''implementation defined'' (depends on the underlying container)}}
{{tdcl list item | {{tt|iterator}} | {{cpp|const_iterator}}}}
+
{{tdcl list item | {{tt|iterator}} | {{|const_iterator}}}}
{{tdcl list item | {{tt|difference_type}} | {{cpp|std::iterator_traits<BidirectionalIterator>::difference_type}}}}
+
{{tdcl list item | {{tt|difference_type}} | {{|std::iterator_traits<BidirectionalIterator>::difference_type}}}}
{{tdcl list item | {{tt|size_type}} | {{cpp|std::allocator_traits<Allocator>::size_type}}}}
+
{{tdcl list item | {{tt|size_type}} | {{|std::allocator_traits<Allocator>::size_type}}}}
{{tdcl list item | {{tt|char_type}} | {{cpp|std::iterator_traits<BidirectionalIterator>::value_type}}}}
+
{{tdcl list item | {{tt|char_type}} | {{|std::iterator_traits<BidirectionalIterator>::value_type}}}}
{{tdcl list item | {{tt|string_type}} | {{cpp|std::basic_string<char_type>}}}}
+
{{tdcl list item | {{tt|string_type}} | {{|std::basic_string<char_type>}}}}
 
{{tdcl list end}}
 
{{tdcl list end}}
  

Revision as of 21:42, 19 April 2012

Template:cpp/regex/match results/sidebar

Defined in header <regex>
template<

    class BidirectionalIterator,
    class Allocator = std::allocator<std::sub_match<BidirectionalIterator>>

> class match_results;
(since C++11)

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 std::regex_search() or std::regex_match() algorithms.

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.

Several specializations for common character sequence types are provided:

Template:tdcl list begin Template:tdcl list header Template:tdcl list hitem Template:tdcl list item Template:tdcl list item Template:tdcl list item Template:tdcl list item Template:tdcl list end

Contents

Member types

Template:tdcl list begin Template:tdcl list hitem Template:tdcl list item Template:tdcl list item