Extract all the Guids from a string C#

This is one of the rare requirement where I had to extract all the Guid from a string and then do the further processing. Now, to do that, I have used Regex.Matches. It will return a MatchCollection containing each Guid. For a string with no Guid, it will return a MatchCollection of length 0.

string strGuid = "5102d73a-1b0b-4461-93cd-0c024738c19e;#5102d73a-1b0b-4461-93cd-0c024733d52d";
string strNoGuid = "someTextButNoGuid";

string pattern = @"([a-z0-9]{8}[-][a-z0-9]{4}[-][a-z0-9]{4}[-][a-z0-9]{4}[-][a-z0-9]{12})";

MatchCollection mc;

//MatchCollection of length 2
mc = Regex.Matches(strGuid, pattern);

//MatchCollection of length 0
mc = Regex.Matches(strNoGuid, pattern); 

Split a String to Array of Strings and Include the Delimiters using .NET C#

To also get the delimiter of the string after the split we’ll have to use Regex.Split. Look at the following code:
string input = "SomeText,SomeText,SomeText,SomeText,SomeText,SomeText"; 
string pattern = "(,)";
string[] substrings = Regex.Split(input, pattern);

OUTPUT
SomeText
,
SomeText
,
SomeText
,
SomeText
,
SomeText
,
SomeText

NOTE: If you remove the parentheses from the pattern, using just “,”, the delimiters will not be preserved.

You can get more info about Regex.Split here