<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國際加速解決方案。 廣告
                工程中,需要從字符串中匹配出以:開頭,并以:結束的字符串。 Google還是百度,很多C++的正則表達式都是通過st::tr1或boost庫中使用的,但是我們僅僅用一個小小的功能,就用一個庫不是很好的辦法。 對的,之前我的博客已經介紹了C++11的新特性-正則表達式。 所以可以不使用其他的庫,來完成任務: ~~~ std::vector<string> all_sub_string = {}; std::string all_string = "12:wo:sfd:wom::sdf"; std::regex e(":[a-z0-9_+-]+:");//正則規則 const std::sregex_token_iterator end; for (std::sregex_token_iterator i(all_string .begin(), all_string .end(), e); i != end; ++i) { all_sub_string .push_back(*i); } ~~~ 你可能會迷惑,什么是sregex_token_iterator? 不要著急,sregex_token_iterator其實就是字符串 regex_token_iterator 的類型定義。 ~~~ typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; ~~~ 上面的方法很簡單,就像使用迭代器一樣。 其實regex還有其他的查找方法,現在介紹一下regex_search: Returns whether some sub-sequence in the target sequence (the subject) matches the regular expression rgx (the pattern). The target sequence is either s or the character sequence between first and last, depending on the version used. 直接上代碼: ~~~ // regex_search example #include <iostream> #include <string> #include <regex> int main () { std::string s ("this subject has a submarine as a subsequence"); std::smatch m; std::regex e ("\\b(sub)([^ ]*)"); // matches words beginning by "sub" std::cout << "Target sequence: " << s << std::endl; std::cout << "Regular expression: /\\b(sub)([^ ]*)/" << std::endl; std::cout << "The following matches and submatches were found:" << std::endl; while (std::regex_search (s,m,e)) { for (auto x:m) std::cout << x << " "; std::cout << std::endl; s = m.suffix().str(); } return 0; } ~~~ 輸出: ~~~ Target sequence: this subject has a submarine as subsequence Regular expression: /\b(sub)([^ ]*)/ The following matches and submatches were found: subject sub ject submarine sub marine subsequence sub sequence ~~~
                  <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>

                              哎呀哎呀视频在线观看