-
Book Overview & Buying
-
Table Of Contents
Object-Oriented JavaScript
By :
When you use regular expressions (discussed in Chapter 4), you can match literal strings, for example:
>>> "some text".match(/me/)
["me"]
But the true power of regular expressions comes from matching patterns, not literal strings. The following table describes the different syntax you can use in your patterns, and provides some examples of their use.
|
Pattern |
Description |
|---|---|
|
|
Matches a class of characters. >>> "some text".match(/[otx]/g) ["o", "t", "x", "t"] |
|
|
A class of characters defined as a range. For example >>> "Some Text".match(/[a-z]/g) ["o", "m", "e", "e", "x", "t"] >>> "Some Text".match(/[a-zA-Z]/g) ["S", "o", "m", "e", "T", "e", "x", "t"] |
|
|
Matches everything that is not matched by the class of characters. >... |
Change the font size
Change margin width
Change background colour