我正在 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/