I need to find the matching GUID in string using Regex
string findGuid="hi sdkfj 1481de3f-281e-9902-f98b-31e9e422431f sdfsf 1481de3f-281e-9902-f98b-31e9e422431f"
var guid = Regex.Match(m.HtmlBody.TextData, @"^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$").Value;
If you would like to get the GUID using a
Regexpattern. Then, try this patternExample
Notice: I’ve used the same pattern you’ve provided but simply removed the
^character which indicates that the expression must match from the start of the string. Then, removed the$character which indicates that the expression must match from the end of the string.More information about Regular Expressions can be found here:
Regular Expressions – a Simple User Guide and Tutorial
Thanks,
I hope you find this helpful 🙂