草庐IT

regex-greedy

全部标签

c++ - regex_match (""8 秒,regex (".{40000}"));?

更新2:实际上是regex(".{40000}");。仅此一项就已经花费了那么多时间。为什么?regex_match("",regex(".{40000}"));在我的PC上花费将近8秒。为什么?难道我做错了什么?我在i7-6700上的Windows10上使用来自MinGW的gcc4.9.3。这是一个完整的测试程序:#include#include#includeusingnamespacestd;intmain(){clock_tt=clock();regex_match("",regex(".{40000}"));cout我如何编译和运行它:C:\Users\...\coding>

c++ - 使用捕获时的 boost::regex 段错误

下面的简单程序出现段错误。好像跟析构函数match_results有关。#include#include#include#includeusingnamespacestd;intmain(intargc,char*argv){boost::regexre;boost::cmatchmatches;boost::regex_match("abc",matches,re.assign("(a)bc"));return0;}编辑:我正在使用boost1.39 最佳答案 boost::regex是boost的少数几个不单独存在于头文件中的组

c++ - 使用 Regex 在 C++ 中进行国际电子邮件验证

我在验证国际电子邮件地址时遇到了一些问题,例如john.doe@神谕.com、sara.smith@神谕.com、babu.ratnakar+आଆఉఊګ神谕@gmail.com,testæœö.神谕#$&*éùôß@äßæçëêùé+आଆ神谕.com在C++中使用REGEX以下Regex在Java中对我来说效果很好:^[\\p{L}0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[\\p{L}0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[\\p{L}0-9](?:[\\p{L}0-9-]*[\\p{L}0-9])?\\.)+[\\p{L}0-9](?:[\\

c++ - 为什么创建 `std::regex` 违反概念?

#define_GLIBCXX_CONCEPT_CHECKS#includevoidf(){std::regexr("hello");}当上面iscompiled作为GCC或Clang中的C++11,会生成一个巨大的模板错误,其关键部分似乎是:/opt/gcc-5.3.0/include/c++/5.3.0/bits/boost_concept_check.h:206:11:error:useofdeletedfunction'std::__detail::_StateSeq>&std::__detail::_StateSeq>::operator=(conststd::__detai

c++ - 不能同时包含 Eigen 和 boost/regex

我可以单独包含每个库,但是一旦我尝试同时包含它们,就会出现大量错误。我正在使用Boostv1_55_0和Eigenv3.2.1。知道可能是什么问题吗?我的包含看起来像这样:#include#include我在下面粘贴了前几个错误,其中有100多个错误。Error1errorC1189:#error:TheEigen/ArrayheaderdoesnolongerexistinEigen3.AllthatfunctionalityhasmovedtoEigen/Core.c:\local\eigen\array81Project12IntelliSense:#errordirective

c++ - 在抛出 'std::regex_error' 实例后调用终止

我只想匹配“{”。但是不知道为什么报这个错:terminatecalledafterthrowinganinstanceof'std::regex_error'what():regex_errorAborted(coredumped)使用g++版本4.6.3在Ubuntu上编译g++-std=c++0xa.c程序#include#includeusingnamespacestd;main(intargc,char**argv){if(regex_match("{1}",std::regex("[{]"))){cout我还检查了ECMAScript细节和这个正则表达式应该匹配。当我使用l

JavaScript Regex在数学运算符上分配,同时将其保留为单独的项目

我有这样的琴弦5+var+"HEH"5+"HEllo!"5我需要用Regex对其进行解析,因此我需要有一个数组['5','+','var','+','"HEH"']['5','+','"HEH"']['5']我尝试了类似的东西/(".+"|\d(?:\.\d+)*)(?:\s*(\+)\s*(".+"|\d(?:\.\d+)*|\w+))*/但是它仅返回第一个匹配组和最后一个。['5','+','"HEH"']['5','+','"HEllo!"']['5']!更新.split()无法使用,因为可以编写解析值,而没有空格。对不起,没有完成描述看答案为什么需要一条正则只做split()vara=

c++ - 当 regex_search 返回 true 时,零是否始终匹配 "matches"?

以下是C++11标准中的一些引用:28.11.3regex_search[re.alg.search]m是regex_search的参数,类型为match_results。2Effects:Determineswhetherthereissomesub-sequencewithin[first,last)thatmatchestheregularexpressione.Theparameterflagsisusedtocontrolhowtheexpressionismatchedagainstthecharactersequence.Returnstrueifsuchasequence

JavaScript Regex多次匹配新线

我仍然挣扎在JavaScript中学习围绕Regex的方式。我正在尝试创建一个将像以下转换的转换器:>thistextshouldbematched->thistextshouldbematched我已经失望了,但是我试图使它变得更加复杂,如下所示:>thisisamatch>soisthis,butshouldbeinthesamematchasabove>thisshouldbeaseperatematch>thisisnothing将等于:thisisamatchsoisthis,butshouldbeinthesamematchasabovethisshouldbeasepera

c++ - boost::regex 和 std::regex 之间的不一致

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Nomatcheswithc++11regex我之前使用boost::regex来处理一些东西,而对于一些我想使用std::regex的新东西,直到我注意到以下不一致-所以问题哪个是正确的?#include#include#include#includevoidtest(std::stringprefix,std::stringstr){std::stringpat=prefix+"\\.\\*.*?";std::cout对我来说(gcc4.7.2,-std=c++11,boost:1.51),我看到了以下内