匯東網


RemoveHTMLLabel 函数 —— C++ 去除 HTML 标签

[編輯] [转简体]
|
作者:huidong | 分類:【編程】C/C++
[ 15 瀏覽 0 評論 2 贊 4 踩 ]

概要

正文

// 移除字符串中的 HTML 标签,返回移除数量
int RemoveHTMLLabel(std::string& str)
{
    for (int i = 0;; i++)
    {
        auto startpos = str.find("<");
        auto endpos = str.find(">") + 1;

        if (startpos == string::npos || endpos == std::string::npos)
        {
            return i;
        }
        else
        {
            str.erase(startpos, endpos - startpos);
        }
    }
}


[ 2] [ 4]


 評論區  0 條評論

+ 添加評論