简体   繁体   English

tr / regex c ++库-regex模式的定义

[英]tr/regex c++ library - definition of regex pattern

How should i define the regex pattern, when i use the tr1/regex library? 使用tr1 / regex库时,应该如何定义正则表达式模式?

#include <tr1/regex>

const regex pattern("[^-]-[^-]");

is not working... When compiling i get error: 'regex' does not name a type 无法正常工作...编译时出现错误:“ regex”未命名类型

regex is in the tr1 namespace so you either need to declare that you are using tr1 or specify that regex is in the tr1 namespace: regextr1命名空间中,因此您需要声明正在使用tr1或指定regextr1命名空间中:

using namespace tr1;

or 要么

const tr1::regex pattern("[^-]-[^-]");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM