• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 20. The RegExp Object: Working w... > Regular Expressions: Characters

Regular Expressions: Characters

In a regular expression, any single character matches itself (unless it is a special character such as $ or ^, as we’ll see later, because those characters have special meaning). For example, I can check whether the user has typed the word exit, by matching to the regular expression /exit/—and if so, display a message:

function checker() 
{ 
    var regexp = /exit/ 
    var matches = document.form1.text1.value.match(regexp) 
    document.form1.text2.value = "You typed exit." 
} 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint