因此,讓我們說我有一個變量包含一個字符串,我想測試它是否匹配我的正則表達式,並且我想知道哪個規則在返回false時被破壞,有沒有辦法讓我知道?爲什麼我的字符串不匹配正則表達式的原因Javascript
這裏是我的代碼,我在測試
var regex = /^(?=.*\d)[a-zA-Z\d]{6,}$/;
var word = "dudeE1123123";
if(word.match(regex)){
console.log("matched");
}else{
console.log("did not match");
console.log("i want to know why it did not match");
}
的原因,我想這是我想通知我的用戶,對於例如:「你不包括大寫字母」或類似的東西
沒有辦法在javascript中,寫自己的正則表達式引擎。 – georg