gpt4 book ai didi

javascript - 比较 2 个字符串时忽略这些字符串中间的数字

转载 作者:行者123 更新时间:2023-11-28 20:02:26 25 4
gpt4 key购买 nike

我正在 Jquery 中比较两个变量值,但这里我需要忽略它们之间的数字。代码如下:

var value1=Earn a score greater than or equal to 3 points for assignment certifictaion Issue Testing ;

var value2=Earn a score greater than or equal to 6 points for assignment certifictaion Issue Testing ;

当使用 j 查询比较两个字符串时,我想要比较而不考虑两个字符串中间存在的数字

最佳答案

为什么不直接用空格替换所有数字呢?和后记比较两个字符串?

var value1 = "Earn a score greater than or equal to 3 points for assignment certifictaion Issue Testing";
var value2= "Earn a score greater than or equal to 61 points for assignment certifictaion Issue Testing";

var result = value1.replace(/\d/g, "") === value2.replace(/\d/g, "");
alert(result)

关于javascript - 比较 2 个字符串时忽略这些字符串中间的数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21430623/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com