I am trying to take input from the textbox now I want to show an alert if the textbox value matches with the regular expression.
I want to check "1702, Belgium" or "Belgium, 1702" using regex but I am getting null.
<script>
$(document).ready(function(){
var r =/+{1702}/;
var v=$(".a").val();
alert(v.match(r));
});
</script>
<body>
<input type="text" class="a" value="1702 Belgium"/>
</body>
/+{1702}/is not a valid regular expression. If you want to check if a string contains1702, you can just use regex/1702/or even simplier -v.indexOf("1702") >= 0+is a repetition operator that's supposed to come after a pattern.{<number>}is used for counted repetitions and not for what you are trying to use it."1702, Belgium"or"Belgium, 1702"then it won't match your value of"1702 Belgium