<html>
<body>
<script type="text/javascript">
var str= "&";
alert(str);
str= str.replace(/\&/g,'&');
alert(str);
</script>
</body>
</html>
Wednesday, February 10, 2010
Wednesday, February 3, 2010
Javascript RegEx - to check whether a string contain numeric value or not.
<script type="text/javascript">
//matches any non-digit in string
var patt1=/\D/;
document.write(patt1.test(""));
document.write("\n");
document.write(patt1.test("@"));
document.write("\n");
document.write(patt1.test("A"));
document.write("\n");
document.write(patt1.test("AAA"));
document.write("\n");
document.write(patt1.test("1"));
document.write("\n");
document.write(patt1.test("111"));
document.write("\n");
document.write(patt1.test("AA111"));
document.write("\n");
</script>
</body>
</html>
Try It
More Regex Patterns
//matches any non-digit in string
var patt1=/\D/;
document.write(patt1.test(""));
document.write("\n");
document.write(patt1.test("@"));
document.write("\n");
document.write(patt1.test("A"));
document.write("\n");
document.write(patt1.test("AAA"));
document.write("\n");
document.write(patt1.test("1"));
document.write("\n");
document.write(patt1.test("111"));
document.write("\n");
document.write(patt1.test("AA111"));
document.write("\n");
</script>
</body>
</html>
Try It
More Regex Patterns
Subscribe to:
Posts (Atom)