c++ - C++11 regex matching a full word that does not end with a period? -


i trying match full word not end period. have following regex negative lookahead, std::regex rex("\\w+(?!\\.)");

however still producing match on words "joe." missing?

you need make sure word followed word boundary:

std::regex rex(r"(\w+\b(?!\.))"); 

see regex demo

otherwise, backtracking occurs , find jo in joe. your pattern.

i advise use raw string literals when defining regex, rid of excessive backslashes way.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -