HTML and CSS Reference
In-Depth Information
Figure 17.12
The user entered
Steven lives in Cleveland
, one uppercase letter
[A-
Z]
, followed by one lowercase letter
[a-z]
, followed by
eve
. This matches both
Steven
and
Cleveland
.
Figure 17.13
When the user entered
Believe!
(top), it didn't match (bottom).
Would it have matched if he or she had entered
BeLieve
. Why?
EXAMPLE
17.13
<html>
<head><title>The Character Class</title></head>
<body>
<script type="text/javascript">
// Character class
1
var reg_expression = /[A-Za-z0-9_]/;
//
A single alphanumeric
//
word character
2
var textString=prompt("Type a string of text","");
3
var result=reg_expression.test(textString);
//
Returns true
//
or false
Continues