std::match_results::position

来自cppreference.com

 
 
正則表達式庫
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_regex(C++11)
sub_match(C++11)
match_results(C++11)
演算法
Original:
Algorithms
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
regex_match(C++11)
regex_search(C++11)
regex_replace(C++11)
迭代器
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
regex_iterator(C++11)
regex_token_iterator(C++11)
例外
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
regex_error(C++11)
性狀
Original:
Traits
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
regex_traits(C++11)
常量
Original:
Constants
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
syntax_option_type(C++11)
match_flag_type(C++11)
error_type(C++11)
 
std::match_results
成員函數
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
match_results::match_results
match_results::~match_results
match_results::operator=
match_results::get_allocator
國家
Original:
State
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
match_results::ready
元素的訪問
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
match_results::size
match_results::max_size
match_results::empty
match_results::length
match_results::position
match_results::str
match_results::operator_at
match_results::prefix
match_results::suffix
迭代器
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
match_results::begin
match_results::cbegin
match_results::end
match_results::cend
格式
Original:
Format
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
match_results::format
修飾符
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
match_results::swap
 
difference_type position( size_type sub = 0 ) const;
(C++11 起)
返回指定子匹配的第一個字元的位置.
Original:
Returns the position of the first character of the specified sub-match.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
如果n == 0,返回整個匹配表達式的第一個字元的位置.
Original:
If n == 0, the position of the first character of entire matched expression is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
如果n > 0 && n < size(),「N​​」個部分,則返回匹配的第一個字元的位置.
Original:
If n > 0 && n < size(), the position of the first character of nth sub-match is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
如果n >= size(),無以倫比的比賽的第一個字元的位置,則返回.
Original:
if n >= size(), a position of the first character of the unmatched match is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目錄

[编辑] 參數

n -
整數,指定相匹配的檢查
Original:
integral number specifying which match to examine
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[编辑] 返回值

指定的匹配的第一個字元或子匹配的位置.
Original:
The position of the first character of the specified match or sub-match.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[编辑] 為例

#include <iostream>
#include <regex>
#include <string>
 
int main()
{
    std::regex re("a(a)*b");
    std::string target("aaab");
    std::smatch sm;
 
    std::regex_match(target, sm, re);
    std::cout << sm.position(1) << '\n';
}

Output:

1

[编辑] 另請參閱

返回指定的子匹配
Original:
returns specified sub-match
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(公共成員函數) [edit]