HTML and CSS Reference
In-Depth Information
Wildcards
So far, we haven't described anything you couldn't find with a simple literal search. The power of regular
expressions is that you can write strings that match several similar strings. For instance, you can write an
expression that matches any start-tag, not just a particular start-tag. To do this, you need wildcards that can
stand in for more than one character.
The first such wildcard is the period. It matches any single character except a line break. For example, the
regular expression 200. matches 2000 , 2001 , 200Z , 200! , and many more strings. The regular expression
a....b matches any six-character string that begins with a and ends with b , such as abbbbb , aaabbb , aDCEFb ,
ab bc b , and many more. Table A.3 shows more examples.
Table A.3. The Period Wildcard
Pattern
Matches
Example
Foo.Bar
Any string beginning with Foo, followed by a
single character, followed by Bar, not containing
any line breaks
FooZBar
FoozBar
Foo Bar
Foo9Bar
.Foo
Any four-character string whose last three letters
are Foo
AFoo
fFoo
9Foo
-Foo
Foo
....
Any four-character string not containing any line
breaks
<em>
This
that
I am
Cat.
2008
..c..
Any five-character string not containing any line
breaks whose middle character is the letter c
Faced
a cat
abcde
The only characters the period doesn't match are the carriage return and the line feed. Because HTML does not
usually consider line breaks to be significant and tags can extend across multiple lines, this is problematic.
Some regular-expression dialects, including Perl's, allow you to modify this behavior so that the period does not
match a line break. However, jEdit's does not.
To match any character, including a line break, you can use the character class [.\s] . More on this shortly.
 
Search WWH ::




Custom Search