• 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: Alternative Mat...

Regular Expressions: Alternative Match Patterns

You also can use alternative match patterns, which enable you to specify a number of different patterns as possible matches. You can specify alternatives by using a bar (|) to separate them. Here’s an example—the user can type exit, or quit, or stop to match this pattern:

function checker() 
{ 
    var regexp = /exit|quit|stop/ 
    var matches = document.form1.text1.value.match(regexp) 
    document.form1.text2.value = "You want to quit?" 
} 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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