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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -