regex class : Matches(string) method

Description

Gets a list of substrings in the argument which match with the regular expression.

Syntax

regexInstance.Matches(string source)

Arguments

ClassNameDescription
stringsourceA string which is searched.

Return value

ClassDescription
list{string}A list of substrings in the argument which match with the regular expression.

Sample code

1:

regex pattern = new regex("(a+)");

2:

list{string} matches = pattern.Matches("aaabbbaaccc"); // "aaa" and "aa".

Notes

It's a wrapper of the System.Text.RegularExpressions.Regex.Matches(String).

If no match is found, return value is empty list.

Links for reference

Copyright © Cooker All rights reserved.