在C++中有一个使用模式匹配(使用正则表达式)的函数吗?

Emi*_*lio 2 c++ regex string

有一个简单的C++方法在字符串上使用模式匹配?代码听起来像这样:

if (regexpcmp("l?nole*[0-9]", "linoleum1")) {
  //we have a match!
} else {
   //no match 
}
Run Code Online (Sandbox Code Playgroud)

Reu*_*nen 11

你有没看过Boost.Regex

const boost::regex e("l?nole*[0-9]");
if (regex_match("linoleum1", e)) {
  //we have a match!
} else {
  //no match 
}
Run Code Online (Sandbox Code Playgroud)