Matching a single literal character(It can be either a lower or upper case character) : Match « Regular Expressions « JavaScript Tutorial






<html>
<head>
<title>Matching a single literal character(It can be either a lower or upper case character) </title>
<script type="text/javascript" language="javascript">
<!-- //
function IsMatchingChar(str){
    var myRegExp = /[aA]/ ;
    return myRegExp.test(str)
}

function TestGuess(){
    alert(IsMatchingChar("A"));
}
// -->
</script>
</head>
<body>
<h3>This page allows you to guess a single
 literal character of either case</h3>
<form>
<button type="Button" onclick="TestGuess()">Click here to guess</button>
</form>
</body>
</html>








26.6.Match
26.6.1.Regular Expressions: /a/
26.6.2.Match: [aA]
26.6.3.Match: AAA|BBB
26.6.4.Match: [A-Z][0-9]
26.6.5.Matching a single literal character(It can be either a lower or upper case character)
26.6.6.Matching sequences of more than one literal character (The format is two upper case letters, a dash and three numbers)
26.6.7.Regular Expression Tester Form
26.6.8.To match words bread, read, or red
26.6.9.To match 'b{0,1}rea{0,1}d'