I. Overview
RegEx. Match Method
Search for matching items of the regular expression in the input string, and return the exact result as a single match object.
Reload list
(1) Search for the regular expression match specified in the RegEx constructor in the specified input string.
[C #] public match (string );
(2) Search for regular expression matching items in the input string from the starting position of the specified input string.
[C #] public match (string, INT );
(3) search the regular expression match provided by the pattern parameter in the specified input string.
[C #] public static match (string, string );
(4) Search for a regular expression match with the length of the specified input string from the start position of the specified input string.
[C #] public match (string, Int, INT );
(5) Search for the matching items of the regular expression provided by the pattern parameter in the input string (the matching options are provided in the options parameter ).
[C #] public static match (string, String, regexoptions );
II. Application Example
1. the following code is used to retrieve the title attribute in the webpage.
Match titlematch = RegEx. Match (filecontents, "<title> ([^ <] *) </title>", regexoptions. ignorecase | regexoptions. multiline );
Filetitle = titlematch. Groups [1]. value;
Note that the groups index obtained by the Red 1 and RegEx. Match Method starts from 1 instead of 0.
2. The following code is used to retrieve the "content" attribute of the webpage header.
Match descriptionmatch = RegEx. match (filecontents, "<meta name =/" Description/"content =/" ([^ <] *)/">", regexoptions. ignorecase | regexoptions. multiline );
Filedesc = descriptionmatch. Groups [1]. value;