<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                C++11中也將正則表達式納入了新標準的一部分,不僅如此,它還支持了6種不同的正則表達式的語法,分別是:`ECMASCRIPT`、`basic`、`extended`、`awk`、`grep和egrep`。其中`ECMASCRIPT`是默認的語法,具體使用哪種語法我們可以在構造正則表達式的時候指定。 正則表達式庫提供表示正則表達式,這是一種用于字符串內執行模式匹配小型的語言的類。 主要的類:? **basic_regex**? regular expression object **sub_match**? identifies the sequence of characters matched by a sub-expression **match_results**? identifies one regular expression match, including all sub-expression matches 算法:? These functions are used to apply the regular expression encapsulated in a regex to a target sequence of characters. **regex_match**? attempts to match a regular expression to an entire character sequence **regex_search**? attempts to match a regular expression to any part of a character sequence **regex_replace**? replaces occurrences of a regular expression with formatted replacement text 迭代器:? The regex iterators are used to traverse the entire set of regular expression matches found within a sequence. **regex_iterator**? iterates through all regex matches within a character sequence **regex_token_iterator**? iterates through the specified sub-expressions within all regex matches in a given string or through unmatched substrings 異常:? This class defines the type of objects thrown as exceptions to report errors from the regular expressions library. **regex_error**? reports errors generated by the regular expressions library 例子代碼: ~~~ #include <iostream> #include <iterator> #include <string> #include <regex> int main() { std::string s = "Some people, when confronted with a problem, think " "\"I know, I'll use regular expressions.\" " "Now they have two problems."; std::regex self_regex("REGULAR EXPRESSIONS", std::regex_constants::ECMAScript | std::regex_constants::icase); if (std::regex_search(s, self_regex)) { std::cout << "Text contains the phrase 'regular expressions'\n"; } std::regex word_regex("(\\S+)"); auto words_begin = std::sregex_iterator(s.begin(), s.end(), word_regex); auto words_end = std::sregex_iterator(); std::cout << "Found " << std::distance(words_begin, words_end) << " words\n"; const int N = 6; std::cout << "Words longer than " << N << " characters:\n"; for (std::sregex_iterator i = words_begin; i != words_end; ++i) { std::smatch match = *i; std::string match_str = match.str(); if (match_str.size() > N) { std::cout << " " << match_str << '\n'; } } std::regex long_word_regex("(\\w{7,})"); std::string new_s = std::regex_replace(s, long_word_regex, "[$&]"); std::cout << new_s << '\n'; } Output: Text contains the phrase 'regular expressions' Found 19 words Words longer than 6 characters: people, confronted problem, regular expressions." problems. Some people, when [confronted] with a [problem], think "I know, I'll use [regular] [expressions]." Now they have two [problems]. ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看