ASP. NET Regular Expression object.

Source: Internet
Author: User

By zkxp
I'm confused. When I think the structure style is a little similar to that of able and datarow. A single record set. Capturecollection, matchcollection, captures, and group are mainly related to understanding this group. A little understandable.

The Regular Expression of Asp.net is located in the space of system. Text. regularexpressions.
Its main objects include capture, capturecollection, group, groupcollection, match, matchcollection, and RegEx.
Another delegate matchevaluator has not been viewed yet.
The regexoptions interface lists some parameters of the Match Method of RegEx. For example, you can specify regexoptions. ignorecase as case insensitive.

In the past, when using regular expressions in ASP, it seems that the while loop is used to continuously search for strings until they cannot be found ,. NET provides a set object that can be searched at a time and put matching in the set for you to get bored.
First look at the RegEx object: The description is an immutable regular expression.
From Main
RegEx. Match Method: searches Regular Expression matches in the input string, and returns the exact result as a single match object.
RegEx. Matches method: enter a string to search for all matching items of the Regular Expression and return all successful matches, just as if match was called multiple times.
RegEx. Match returns a single matching result that can be stored in the match object.
RegEx. Matches returns all matching results stored in the matchcollection object.

Match Class: Indicates the matching result of a single regular expression.
Store a single result of the RegEx. Match method. A match object is a set. However, all matching results are stored in the match. groups object, and the next matching result can be returned through match. nextmatch. Like whether there are other records returned by datareader. Read. Match. Success can return whether there is another match.
You can use the following method to traverse all matches.
While (M. Success)
{
M = M. nextmath;
}
Matchcollection class: Applies the regular expression pattern to the set of successful matches found in the input string in iterative mode.
All matching sets are placed. It is mainly used for its indexer and count attributes. Matchcollection [I].
From this column, we can see the relationship with match:
Private void T6 ()
{
/* Comprehensive Exercises */
String TXT = "123abc4abcd ";
RegEx r = new RegEx ("ABC ");
Matchcollection MC = R. Matches (txt );
For (INT I = 0; I <MC. Count; I ++)
{
Match m = mc [I];
}
}
Like datatable and datarow.
Capture class:Displays the results captured by a single subexpression.CaptureIndicates a substring that is successfully captured.
Capturecollection class: Represents a sequence of captured substrings.CapturecollectionReturns the set of captures executed by a single capture group.
After testing the code, it seems like this. The match object stores all matching results through the RegEx. Match method.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.