Match: [aA] : Match « Regular Expressions « JavaScript Tutorial

Home
JavaScript Tutorial
1.Language Basics
2.Operators
3.Statement
4.Development
5.Number Data Type
6.String
7.Function
8.Global
9.Math
10.Form
11.Array
12.Date
13.Dialogs
14.Document
15.Event
16.Location
17.Navigator
18.Screen
19.Window
20.History
21.HTML Tags
22.Style
23.DOM Node
24.Drag Drop
25.Object Oriented
26.Regular Expressions
27.XML
28.GUI Components
29.Dojo toolkit
30.jQuery
31.Animation
32.MS JScript
JavaScript Tutorial » Regular Expressions » Match 
26.6.2.Match: [aA]
<html>
<head>
<title>Matching a single literal character</title>
<script type="text/javascript" language="javascript">
<!-- //
function IsMatchingChar(str){
    var myRegExp = /[aA]/ ;
    return myRegExp.test(str)
}

function TestGuess(){
    alert(IsMatchingChar('A'));
    alert(IsMatchingChar('a'));
}
// -->
</script>
</head>
<body>

<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'
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.