RegExp.test
In this chapter you will learn:
RegExp's test()
RegExp.test()
accepts a string argument and returns true
if the pattern matches and false if it does not.
<!DOCTYPE html><!--from j av a2 s .c o m-->
<html>
<head>
<script type="text/javascript">
var text = "000-00-0000";
var pattern = /\d{3}-\d{2}-\d{4}/;
if (pattern.test(text)){
document.writeln("The pattern was matched.");
}
</script>
</head>
<body>
</body>
</html>
Next chapter...
What you will learn in the next chapter:
Home » Javascript Tutorial » Regular Expressions