dengxiaozhen(狐狸) - 2019-05-23 0 人
cursor: help
lcc597084(null) - 2019-05-23 0 人
练习 vue 2019
lcc597084(null) - 2019-05-23 0 人
练习vue得2019
canon(前端大神) - 2019-05-23 0 人
本作品暂无说明
/**
 * 阿里关键词屏蔽原文对比,找到屏蔽前所对应的关键词位置
 * @sourceContent 原始内容
 * @destContent 屏蔽后内容
 * @return word屏蔽关键词, start,end关键词在原文中的开始与结束位置, blockpos屏蔽后内容*号位置:[start, end]
 */
function contentDiff(sourceContent, destContent) {
    result = [];

    len1 = sourceContent.length;
    len2 = destContent.length;

    sPointer = 0;
    dPointer = 0;
    while (sPointer < len1) {
        if (sPointer >= len2) {
            break;
        }

        if (sourceContent[sPointer] == destContent[dPointer]) {
            sPointer++;
            dPointer++;
            continue;
        }

        blockWord = {
            'word': '',
            'start': sPointer,
            'end': -1,
            'blockpos':[]
        };

        if (destContent[dPointer] != '*') {
            sPointer++;
            dPointer++;
            continue;
        }

        blockWord.blockpos[0] = dPointer;
        while (destContent[dPointer] == '*') {
            dPointer++;
        }
        blockWord.blockpos[1] = dPointer - 1;

        blockWord['start'] = sPointer;
        while (sourceContent[sPointer] != destContent[dPointer]) {
            blockWord.word += sourceContent[sPointer];
            sPointer++;
        }
        blockWord.end = sPointer - 1;

        result.push(blockWord);
    }
    return result;
}

src = '工01困粗百3要国34567在89';
dest = '工01***3*56***89';
diff = contentDiff(src, dest);
console.log(diff);
ideamean(null) - 2019-05-23 0 人
关键词屏蔽diff
roft(醉乂皓月) - 2019-05-23 0 人
自动点击啊
没有了
1/3036 下一页