std::regex_match – cppreference.com
Aus cppreference.com
<metanoindex/>
<tbody> </tbody>
| definiert in Header <regex> |
||
|
|
(1) | (seit C++11) |
|
|
(2) | (seit C++11) |
|
|
(3) | (seit C++11) |
|
|
(4) | (seit C++11) |
|
|
(5) | (seit C++11) |
|
|
(6) | (seit C++11) |
1)
Legt fest, ob es eine Übereinstimmung zwischen dem regulären Ausdruck e und der gesamten Ziel-Zeichenfolge [first,last), unter Berücksichtigung der Wirkung von flags. Spiel Ergebnisse sind in m zurückgegeben .
Original:
Determines if there is a match between the regular expression e and the entire target character sequence [first,last), taking into account the effect of flags. Match results are returned in m.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
Verhält sich wie (1) oben, unter Weglassung der Spielergebnisse .
Original:
Behaves as (1) above, omitting the match results.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3)
Versandkosten std::regex_match(str, str + std::char_traits<charT>::length(str), m, e, flags) .
Original:
Returns std::regex_match(str, str + std::char_traits<charT>::length(str), m, e, flags).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
4)
Versandkosten std::regex_match(s.begin(), s.end(), m, e, flags) .
Original:
Returns std::regex_match(s.begin(), s.end(), m, e, flags).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5)
Versandkosten std::regex_match(str, str + std::char_traits<charT>::length(str), e, flags) .
Original:
Returns std::regex_match(str, str + std::char_traits<charT>::length(str), e, flags).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
6)
Versandkosten std::regex_match(s.begin(), s.end(), e, flags) .
Original:
Returns std::regex_match(s.begin(), s.end(), e, flags).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Parameter
| first, last | - | das Ziel Zeichenbereich, um die regex gelten, gegeben als Iteratoren Original: the target character range to apply the regex to, given as iterators The text has been machine-translated via Google Translate. |
| m | - | die Spielergebnisse Original: the match results The text has been machine-translated via Google Translate. |
| str | - | die Zielzeichenfolge als null-terminierte C-String gegeben Original: the target string, given as a null-terminated C-style string The text has been machine-translated via Google Translate. |
| s | - | das Ziel string, als std::basic_string gegeben Original: the target string, given as a std::basic_string The text has been machine-translated via Google Translate. |
| e | - | Der reguläre Ausdruck Original: the regular expression The text has been machine-translated via Google Translate. |
| flags | - | Flags verwendet, um zu bestimmen, wie das Spiel gespielt wird Original: flags used to determine how the match will be performed The text has been machine-translated via Google Translate. |
| Type requirements | ||
-BidirIt must meet the requirements of BidirectionalIterator.
| ||
Rückgabewert
true kehrt, wenn eine Übereinstimmung besteht, false anders angegeben. In jedem Fall wird das Objekt m wie folgt aktualisiert:
Original:
Returns true if a match exists, false otherwise. In either case, the object m is updated, as follows:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn das Spiel existiert nicht:
Original:
If the match does not exist:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
m.ready() == true
| |
m.empty() == true
| |
m.size() == 0
|
Wenn das Spiel vorhanden ist:
Original:
If the match exists:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
m.ready()
|
true
|
m.empty()
|
false
|
m.size()
|
Anzahl der Unterausdrücken plus 1, das heißt, Original: number of subexpressions plus 1, that is, The text has been machine-translated via Google Translate. |
m.prefix().first
|
first
|
m.prefix().second
|
first
|
m.prefix().matched
|
Original:
The text has been machine-translated via Google Translate. |
m.suffix().first
|
last
|
m.suffix().second
|
last
|
m.suffix().matched
|
Original:
The text has been machine-translated via Google Translate. |
m[0].first
|
first
|
m[0].second
|
last
|
m[0].matched
|
Original:
The text has been machine-translated via Google Translate. |
m[n].first
|
der Beginn der Sequenz, die Unterausdruck n oder Original: the start of the sequence that matched sub-expression n, or The text has been machine-translated via Google Translate. |
m[n].second
|
das Ende der Sequenz, die sub-Ausdruck n oder Original: the end of the sequence that matched sub-expression n, or The text has been machine-translated via Google Translate. |
m[n].matched
|
Original:
The text has been machine-translated via Google Translate. |
Beispiel
#include <iostream> #include <string> #include <regex> int main() { std::string fnames[] = {"foo.txt", "bar.txt", "zoidberg"}; std::regex txt_regex("[a-z]+\\.txt"); for (const auto &fname : fnames) { std::cout << fname << ": " << std::regex_match(fname, txt_regex) << '\n'; } }
Output:
foo.txt: 1 bar.txt: 1 zoidberg: 0
Siehe auch
regulären Ausdrucks Original: regular expression object The text has been machine-translated via Google Translate. (Klassen-Template) [edit] | |
identifiziert einen regulären Ausdruck, inkl. aller Unterseiten Ausdruck übereinstimmt Original: identifies one regular expression match, including all sub-expression matches The text has been machine-translated via Google Translate. (Klassen-Template) [edit] | |