我在比较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查询比较两个字符串时,无论两个字符串中间是否存在数字,我都希望进行比较
答案 0 :(得分:3)
为什么不用空格替换所有数字?然后比较两个字符串?
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)