germachines.blogg.se

Capture definition
Capture definition




capture definition

Gets the captured span from the input string.ĭetermines whether the specified object is equal to the current object.Ĭreates a shallow copy of the current Object.

capture definition

Gets the captured substring from the input string.

capture definition

Gets the length of the captured substring. The position in the original string where the first character of the captured substring is found. If you do apply a quantifier to a capturing group, the Group.Index, Group.Length, and Group.Value properties provide information only about the last captured group, whereas the Capture objects in the CaptureCollection provide information about all subexpression captures. If you do not apply a quantifier to a capturing group, the Group.Captures property returns a CaptureCollection with a single Capture object that provides information about the same capture as the Group object. However, the Match.Captures property provides information about the same match as the Match object. Instances are returned through the CaptureCollection object, which is returned by the Match.Captures and Group.Captures properties. RemarksĪ Capture object is immutable and has no public constructor. The Capture objects in the second capturing group's collection of captures contain information about each captured word. The Capture objects in the first capturing group's collection of captures contain information about each captured word and white-space character or period. However, the Capture objects in the group's CaptureCollection object capture each subexpression match.

capture definition

Group 2, which represents the second capture, contains the last word in the sentence. Group 1, which represents the first capture, contains the last word in the sentence that has a closing period. The second sentence consists of multiple words, so the Group objects only contain information about the last matched subexpression. As the output shows, the first sentence consists of only one word, so the CaptureCollection object has a single Capture object that represents the same capture as the Group object. In this example, the input string consists of two sentences. Match one or more occurrences of a word character or characters followed by a white-space character or period ("."). Match one or more word characters followed by a white-space character or period ("."). Match a white-space character or period ("."). Note that in this regular expression, a quantifier (+) is applied to the entire regular expression. The regular expression pattern ((\w+))+ is defined as shown in the following table. ' The example displays the following output: String pattern = (Match match in Regex.Matches(input, pattern))Ĭonsole.WriteLine("Match: ", captureCtr, _ The following example defines a regular expression that matches sentences that contain no punctuation except for a period (".").






Capture definition