<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>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## Regex ### 頭文件: `"boost/regex.hpp"` 正則表達式被封裝為一個類型 `basic_regex`的對象。我們將在下一節更深入地討論正則表達式如何被編譯和分析,這里我們首先粗略地看看 `basic_regex` ,以及這個庫中三個最重要的算法。 ``` namespace boost { template <class charT, class traits=regex_traits<charT> > class basic_regex { public: explicit basic_regex( const charT* p, flag_type f=regex_constants::normal); bool empty() const; unsigned mark_count() const; flag_type flags() const; }; typedef basic_regex<char> regex; typedef basic_regex<wchar_t> wregex; } ``` ### 成員函數 ``` explicit basic_regex ( const charT* p, flag_type f=regex_constants::normal); ``` 這個構造函數接受一個包含正則表達式的字符序列,還有一個參數用于指定使用正則表達式時的選項,例如是否忽略大小寫。如果`p`中的正則表達式無效,則拋出一個 `bad_expression` 或 `regex_error` 的異常。注意這兩個異常其實是同一個東西;在寫這本書之時,尚未改變當前使用的名字 `bad_expression` ,但下一個版本的Boost.Regex將會使用 `regex_error`. ``` bool empty() const; ``` 這個成員函數是一個謂詞,當`basic_regex`實例沒有包含一個有效的正則表達式時返回 `true` ,即它被賦予一個空的字符序列時。 ``` unsigned mark_count() const; ``` `mark_count` 返回`regex`中帶標記子表達式的數量。帶標記子表達式是指正則表達式中用圓括號括起來的部分。匹配這個子表達式的文本可以通過調用某個正則表達式算法而獲得。 ``` flag_type flags() const; ``` 返回一個位掩碼,其中包含這個`basic_regex`所設置的選項標志。例如標志 `icase`, 表示正則表達式忽略大小寫,標志 `JavaScript`, 表示regex使用JavaScript的語法。 ``` typedef basic_regex<char> regex; typedef basic_regex<wchar_t> wregex; ``` 不要使用類型 `basic_regex`來定義變量,你應該使用這兩個`typedef`中的一個。這兩個類型,`regex` 和 `wregex`, 是兩種字符類型的縮寫,就如 `string` 和 `wstring` 是 `basic_string&lt;char&gt;` 和 `basic_string&lt;wchar_t&gt;`的縮寫一樣。這種相似性是不一樣的,某種程度上,`regex` 是一個特定類型的字符串的容器。 ### 普通函數 ``` template <class charT,class Allocator,class traits > bool regex_match( const charT* str, match_results<const charT*,Allocator>& m, const basic_regex<charT,traits >& e, match_flag_type flags = match_default); ``` `regex_match` 判斷一個正則表達式(參數 `e`)是否匹配整個字符序列 `str`. 它主要用于驗證文本。注意,這個正則表達式必須匹配被分析串的全部,否則函數返回 `false`. 如果整個序列被成功匹配,`regex_match` 返回 `True`. ``` template <class charT,class Allocator, class traits> bool regex_search( const charT* str, match_results<const charT*,Allocator>& m, const basic_regex<charT,traits >& e, match_flag_type flags = match_default); ``` `regex_search` 類似于 `regex_match`, 但它不要求整個字符序列完全匹配。你可以用 `regex_search` 來查找輸入中的一個子序列,該子序列匹配正則表達式 `e`. ``` template <class traits,class charT> basic_string<charT> regex_replace( const basic_string<charT>& s, const basic_regex<charT,traits >& e, const basic_string<charT>& fmt, match_flag_type flags = match_default); ``` `regex_replace` 在整個字符序列中查找正則表達式`e`的所有匹配。這個算法每次成功匹配后,就根據參數`fmt`對匹配字符串進行格式化。缺省情況下,不匹配的文本不會被修改,即文本會被輸出但沒有改變。 這三個算法都有幾個不同的重載形式:一個接受 `const charT*` (`charT` 為字符類型), 另一個接受 `const basic_string&lt;charT&gt;&`, 還有一個重載接受兩個雙向迭代器作為輸入參數。
                  <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>

                              哎呀哎呀视频在线观看