Skip to content
Discussion options

You must be logged in to vote

如果只是判断字符串是否包含某个子串,没必要正则吧,

int main()
{
    string a{"冬奥会纪念币"};
    cout << a.find("纪念币") << endl;
    cout << (a.find("冰墩墩") == string::npos ? "未找到":"找到了");
    return 0;
}

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by RicoloveFeng
Comment options

You must be logged in to vote
1 reply
@RicoloveFeng
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants