Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在regex cpp中使用变量_C++_Regex - Fatal编程技术网

C++ 在regex cpp中使用变量

C++ 在regex cpp中使用变量,c++,regex,C++,Regex,我有一个字符串: string str1= "hello"; string str2="hel"; 我这样做是为了看看str1中是否含有str2: regex e = str2+"*" bool x=regex_match(str1,e); cout<<x; regex e=str2+“*” boolx=正则表达式匹配(str1,e); 看一下关于regex的构造函数的参考资料 template <class ST, class SA> explicit b

我有一个字符串:

string str1= "hello"; 
string str2="hel"; 
我这样做是为了看看str1中是否含有str2:

regex e = str2+"*"
 bool x=regex_match(str1,e); 
cout<<x; 
regex e=str2+“*”
boolx=正则表达式匹配(str1,e);

看一下关于
regex的构造函数的参考资料

template <class ST, class SA>
explicit basic_regex ( const basic_string<charT,ST,SA>& str, flag_type flags = 
 ECMAScript );
不是


查看哪些类型是
str1
str2
hello
hel
?它们是如何定义的?你能提供产生这个问题的完整代码吗?@WiktorStribiżew这个问题是关于串接的!还要注意,正则表达式
hel*
将匹配
hello
,但这不是您可能认为的原因。在您的真实代码中,hello
是否有引号,或者它是另一个变量?
    regex e(str2+"*");
    regex e = str2+"*";