If I understand correctly, the following simple pattern should work for you:
^d*(?:hello)?d*$
You may use the regex in case insensitive mode. Example:
var inputs = ["123Hello", "hello", "123", "hello word", "he123llo", "he llo 123"];
inputs.forEach(function(input) {
if (/^d*(?:hello)?d*$/i.test(input)) {
console.log(input + ": VALID");
}
else {
console.log(input + ": INVALID");
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…