Check if a string contains brackets with an integer in it
I want to check if a string in javascript contains regular brackets with an integer in it
var str="(12) this is a test";
var pat=/(([\d]+))/;
if (pat.test(str))
alert("true");
Works fine, but also returns true when the string looks like this:
var str="12) test";
var str="(12 test";
which should return false.
+3
source to share