A question about regular expressions

Hi,

I have a variable string and I would like to check whether it contains the following or not:

“digit”+“digit”+“:”

For example: “02:”, “45:”, “13:”, “88:” etc.

I tried the following but it didn’t work:

myString.indexOf(/[0-9]{2}$/+':')

Thanks for any ideas.

Hi,

\d will match any digit and the colon is just a normal character, so you could write:

var str="This is my string 99:99"; 
if (str.match(/\\d\\d:/)){
  alert("Match found");
}

HTH

Thanks a lot, it worked.