["c# regex","","37 C# ","A+.wrsyyzXbCST~~}T~~YF6A9564F1BCXB/CEES}T~~}T~~","Regex.Matches"," returns multiple Match objects. It matches multiple instances of a pattern and returns a MatchCollection. It is useful for extracting values, based on a pattern, when many are expected.","To start,"," this program includes the System.Text.RegularExpressions namespace. It uses an input string that contains several words. Each one starts with the letter s. Next, we use Regex.Matches on this string. ","Pattern: ","This will only match words starting with the letter s, with one or more non-whitespace characters, and ending in a lowercase d.","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto","Based on:"," .NET 4.5\n\n","C# program that uses Regex.Matches method","\n\nusing System;\nusing System.Text.RegularExpressions;\n\nclass Program\n{\n static void Main()\n {","\n // Input string.\n ","const string value = ","@\"said shed see spear spread super\";","\n\n // Get a collection of matches.\n ","MatchCollection matches = ","Regex.Matches","(value, ","@\"s\\w+d\"",");","\n\n // Use foreach-loop.\n ","foreach (Match match in matches)\n {\n foreach (Capture capture in match.Captures)\n {\n Console.WriteLine(","\"Index={0}, Value={1}\"",", capture.Index, capture.Value);\n }\n }\n }\n}\n\n","Output","\n\nIndex=0, Value=said\nIndex=5, Value=shed\nIndex=20, Value=spread","Foreach loop."," Next we use the foreach-loop on the MatchCollection returned by Regex.Matches. To access the individual pieces matched by the Regex, we need to loop over the Captures collection. ","Foreach ","foreach","Finally: ","We can access the Value property to get the actual string. The Index property tells us the character position of the capture.","Matches vs. Match."," With Regex.Matches, we gather a group of matches (a MatchCollection) which must be iterated over. If only one Match is needed, Regex.Match is simpler to use. And the simplest method is typically best. ","Regex.Match ","regex","Summary."," The Regex.Matches method provides a way for you to match multiple times in a single input string. You can then loop over these matches and their individual captures to get all the results. It is similar to Regex.Match. ","Note: ","Doing this sort of text processing would be more cumbersome if you were to use methods such as IndexOf and Split.","IndexOf ","indexof","Split ","split","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","3679700504","data-ad-format","link","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto"]

%iVBORw0KG;)NSUhEUg?AM0?ABICAM?ABiH4Ew)GFBMVEV9fX2owomVpISHjYHC64274IzP/5H6+voBAFkX?ACPUlEQVR4Xu2b4arbMAyFdY4k9/3feN26KxQlV7AtCYvx96tBHKqPuLJTiLxeL1CeD/E2eduozIG+bUJmBh2BzAOEMg0PdVksFovFYrFYeAGgymMZBximsAlMp7AJdCobPHQKWCwv98ffHMGXAPPFwAQ2gqls5Dsbwn8Cyg4CnwID7ZPKjKYgz7WxQxvat7sRvkrOEaBPskycEfj190a97kZVs4ImeaMNDmaa2igwSuMYNMnbbPRwCPioWC1V0CSvt6mg6FZQShU0ybttoFFNc8Eo0YZtS8M0d0hqk6xrUEMcZ0zoXoabb2W+0PxzSDp9suqYhsyZNv1C883BjhtR296pPrkbIKYhc56NWdEpM8B/0Rwc4rJPppuewdlnAUXosNhUeps+eajjcrJNXix+sU0EAp5tkxuQ3kb/2kaLTcALnwhE3JHrjsw2auEdNl0y1y3NtittxvBcN9nBkbOastIms4xq0rnMhvrbRuvQoVFkv3uqF5suGTNARdROG2tANAEgbPIo8LyrKhFLPMub28g2fVJJfgqkfD7G5b9QuueBDccebY/QItImc8G3w8LPtBFrzpbdg0q1aZI32vBomPqouJZ+q02TvNEmt4cyKXIlYKgCyaZJ3meT26Nseg4MevD/BzScXfpkb3M2SgAsBQX8TS0cPaOiSf7XYBgONq7nEdungSrCkDF5KGwOyc/Dxx7IU8EUMoH6BDLNfvJ0lIA78Ecqi8VisVgsFgtO5QKZB0z1ptdkb+HN9YbkD2u1NmxyY6u4)AElFTkSuQmCC%iVBORw0KG;)NSUhEUg?AP).CAM)Bfxb6)YFBMVEX::0nML5yt74wNj73ev74Oz97/X2q8v3uNP1ocX5zd/5xtz1pcj3tdH72ef2sM761OT++vv4vdf85e/5xNv+9/r8/Pzz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