TAILIEUCHUNG - Professional ASP.NET 1.0 Special Edition- P31

Professional Special Edition- P31:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | Dim expr As String h e ll o Dim re As New Regex expr mt Hello everyone hello one and all. For Each gp In br Next This returns the following hello ello ll There are three matches. The first is the entire match expression the second corresponds to the group within the first set of parentheses and the third is the group within the second set of parentheses. The Group class also includes Index and Length properties that indicate the position of the match within the search string and the length of string that is matched. The Capture Class The Capture class represents a single sub-expression capture. Each Group can have multiple captures. The Capture class really comes into its own when quantifiers are used within expressions. Quantifiers add an optional quantity to finding patterns. Examples of quantifiers are for zero or more occurrences and for one or more occurrences. For example consider the following expression which searches for the first occurrence of one or more 1 characters. l Putting this into a full example we have @ Page Language VB Dim mt As Match Dim gp As Group Dim cp As Capture Dim expr As String l Dim re As New Regex expr mt Hello everyone hello one and all. For Each gp In Group br For Each cp In Capture br Next Next This gives the following result Group ll Capture ll Group l Capture l Capture l Both a single 1 and multiple 1 characters are matched because the quantifier specifies one or more. So the first group matches the 11 in the first Hello. For the second group there are two occurrences of single 1 characters. This becomes clearer with another example- consider the following match expression abc This matches one or more occurrences of the string abc. When matched against QQQabcabcabcWWWEEEabcab we get the following output Group .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU HOT