boost-xpressive

    1熱度

    2回答

    我可以用xpressive中Boost庫的做一些正則表達式替換這樣的: #include <iostream> #include <boost/xpressive/xpressive.hpp> void replace(){ std::string in("a(bc) de(fg)"); sregex re = +_w >> '(' >> (s1= +_w) >> ')'

    3熱度

    1回答

    string str = "hello world!\r\naa=`xxx_1`\r\nhello world!"; sregex rx = sregex::compile(".+=`(.+)_1`"); smatch what; if(regex_match(str, what, rx)) { std::cout << what[1] << '\n'; } 這不能工作,我

    2熱度

    1回答

    我有一個升壓xpressive中sregex和語義作用等同於以下內容: Rule = ('[' >> (s1=!(set=')',']','>')))[some_op(as<std::string>(s1))]; 以前我是用這個升壓1.43沒有任何問題。我最近不得不升級到更新的版本,現在我遇到了以下問題。 當submatch不匹配任何內容(因爲它是可選的)時,在提升1.48時,當as在空對象上

    0熱度

    1回答

    我只是無法獲得regex_match函數來查找不區分大小寫的匹配。儘管boost::xpressive::regex_constants::icase是defined我用鑄造(所以沒有歧義,以xpressive中的icase方法),我得到一個編譯錯誤(VS2010): 錯誤C2440:「類型轉換」:不能從轉換'常量的boost :: xpressive中::詳細:: modifier_op' 到

    1熱度

    1回答

    我注意到當我在代碼中使用xp :: sregex :: compile時,字符串... \ 3rdparty \ boost-1_58 \ boost/xpressive/detail/core/matcher/regex_byref_matcher.hpp(用我的本地路徑)出現在二進制代碼中,在發佈mods中編譯。 有沒有辦法刪除它?

    2熱度

    1回答

    用ANSI C PCRE我可以通過以下方式提取部分及其內容: (?ms)^\\[(.+?)\\](.*?)(?=\\n\\[|.\\z) 從[sec1] a = b [sec2] c = d 我[sec1] a = b和[sec2] c = d 但我如何能在xpressive中做到這一點?

    2熱度

    1回答

    我注意到boost xpressive sregex任務中的奇怪行爲。請參閱下面的代碼。第一個不起作用的代碼片段具有sregex對象初步分配,然後在主表達式中使用。第二個工作良好的代碼片段沒有先前的sregex分配(除了最後一個主分配)。如果我錯誤地使用boost xpressive api,請告訴我。不起作用 mark_tag Value1(1), Value2(2), Value3(3), V

    3熱度

    1回答

    我正在使用boost :: xpressive來解析我的文本文件。我想看看是否只有當行以'#'開頭(多次)。 我使用下面的代碼 std::string str1 = "## this could be my line"; sregex rex1 = sregex::compile("^#+"); smatch result1; if(regex_match(str1,result1,rex1

    2熱度

    2回答

    Edit8:我已經發布瞭解決方案,首先爲任何可能在我之後出現同樣問題的人解決。 解: 分配正則表達式=與不是調用()運算符。工作很好。那很愚蠢。 #include <iostream> #include <string> #include <boost/xpressive/xpressive_dynamic.hpp> int main() { std::string str =

    1熱度

    1回答

    (或因此我認爲)... 我使用boost :: xpressive中爲我的正則表達式引擎解析的東西,我得到一個段錯誤。我懷疑遞歸和我的糟糕的正則表達式都是怪罪,因爲gdb顯示了超過300個堆棧幀。所以,這裏是我的(區分大小寫)的正則表達式,在Perl/Python的符號: begin([^e]+)e((?:[^b]|b(?!egin))+) ,我期待與第一大寫文字匹配 beginHEADER