【问题标题】:how to compare the string and store the difference in a variable. c++如何比较字符串并将差异存储在变量中。 C++
【发布时间】:2016-05-30 07:08:45
【问题描述】:
str1="D:\\User\\Desktop\\result.jpg";
str2="D:\\User\\Desktop\\";

我想得到 str1 和 str2 之间的区别,即“result.jpg”,以便我可以将字符串“result.jpg”用于其他内容。 有什么解决办法吗?

【问题讨论】:

标签: string compare


【解决方案1】:

我会使用字符串替换和查找:

std::string string = std::regex_replace(string1, std::regex("\\" + str2), "");

这只是伪代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多