Again, regex_match() yields true.
Here, we use the concept of “grouping.” We use “(...)” to define a so-called capture group, to which we refer later on with the regular expression “1”. Note, however, that we specify the regular expression as an ordinary character sequence, so we have to specify the “character followed by the character 1” as “\1”. Alternatively, we could use a raw string, which was introduced with C++11 (see Section 3.1.6, page 23):
R"(.*)" // equivalent to: ".*"
Such a raw string allows you to define a character sequence by writing exactly its contents as a raw character sequence. It starts with “R"(” and ends with “)"”. To be able to have “)"” inside the raw string, you can use a delimiter. Thus, the complete syntax of raw strings is R"delim(...)delim", where delim is a character sequence of at most 16 basic characters except the backslash, whitespaces, and parentheses.
What we introduce here as special characters for regular expressions is part of the grammar they have. Note that the C++ standard library supports various grammars. The default grammar is a “modified ECMAScript grammar,” which is introduced in detail in Section 14.8, page 738. But the next statements show how a different grammar can be used:
Again, regex_match() yields true.
Here, we use the concept of “grouping.” We use “(...)” to define a so-called capture group, to which we refer later on with the regular expression “1”. Note, however, that we specify the regular expression as an ordinary character sequence, so we have to specify the “character followed by the character 1” as “\1”. Alternatively, we could use a raw string, which was introduced with C++11 (see Section 3.1.6, page 23):
R"(<(.*)>.*)" // equivalent to: "<(.*)>.*"
Such a raw string allows you to define a character sequence by writing exactly its contents as a raw character sequence. It starts with “R"(” and ends with “)"”. To be able to have “)"” inside the raw string, you can use a delimiter. Thus, the complete syntax of raw strings is R"delim(...)delim", where delim is a character sequence of at most 16 basic characters except the backslash, whitespaces, and parentheses.
What we introduce here as special characters for regular expressions is part of the grammar they have. Note that the C++ standard library supports various grammars. The default grammar is a “modified ECMAScript grammar,” which is introduced in detail in Section 14.8, page 738. But the next statements show how a different grammar can be used:
การแปล กรุณารอสักครู่..