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 -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

java - How to implement an entity bound odata action in olingo v4.3 -