
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
560
|
Chapter 10: Regular Expressions
The following text will be displayed:
UNIQUE MATCHES
<!-- My comment -->
<![CDATA[<escaped> <><chars>>>>>]]>
</Control>
</Window>
<?xml version="1.0\" encoding=\"UTF-8\"?>
<Control ID="Label">
<Control ID="TextBox">
<Property Top="0" Left="0" Caption="Enter Name Here"/>
<Property Top="0" Left="0" Text="BLANK"/>
<Window ID="Main">
ALL MATCHES
<?xml version="1.0\" encoding=\"UTF-8\"?>
<!-- my comment -->
<![CDATA[<escaped> <><chars>>>>>]]>
<Window ID="Main">
<Control ID="TextBox">
<Property Top="0" Left="0" Text="BLANK"/>
</Control>
<Control ID="Label">
<Property Top="0" Left="0" Caption="Enter Name Here"/>
</Control>
<Control ID="Label">
<Property Top="0" Left="0" Caption="Enter Name Here"/>
</Control>
</Window>
Discussion
As you can see, the regular expression classes in the FCL are quite easy to use. The
first step is to create an instance of the
Regex object that contains the regular expres-
sion pattern, along with any options for running this pattern. The second step is to
get a reference to an instance of the
Match object, if you need only the first found
match, or a
MatchCollection object, if you need more than just the first found match.
To get a reference to this object, the two instance methods
Match and Matches can be
called from the
Regex object that was created ...