解决方法
这样的事情应该做到这一点:
string val = "name='40474740-1e40-47ce-aeba-ebd1eb1630c0'"; Match match = Regex.Match(val,@"'([^']*)"); if (match.Success) { string yourValue = match.Groups[1].Value; Console.WriteLine(yourValue); }
表达式“([^’] *)的解释:
' -> find a single quotation mark ( -> start a matching group [^'] -> match any character that is not a single quotation mark * -> ...zero or more times ) -> end the matching group