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

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -