Matches set description

Source: Internet
Author: User

Matches set
A set of regular expressions that match objects.

Description
The matches set contains several independent match objects, which can only be created using the execute method of the Regexp object. Similar to an independent match object attribute, one attribute of the matches set is read-only.

When executing a regular expression, zero or multiple match objects may be generated. Each match object provides the access entry of the string that matches the regular expression, the length of the string, and the index that identifies the matching position.

The following code describes how to use a regular expression to search for a matches set and how to traverse the set cyclically:

Function regexptest (patrn, strng)
Dim RegEx, match, matches 'to create variables.
Set RegEx = new Regexp 'to create a regular expression.
RegEx. pattern = patrn 'setting mode.
RegEx. ignorecase = true' is used to set Case sensitivity.
RegEx. Global = true' sets full match.
Set matches = RegEx. Execute (strng) 'to execute the search.
For each match in matches 'cyclically traverses the matches set.
Retstr = retstr & "match found at position"
Retstr = retstr & Match. firstindex & ". Match value is '"
Retstr = retstr & Match. Value & "'." & vbcrlf
Next
Regexptest = retstr
End Function
Msgbox (regexptest ("is.", "is1 is2 is3 is4 "))

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.