string val = "name='40474740-1e40-47ce-aeba-ebd1eb1630c0'";
我想'使用正则表达式获取引号之间的文本。
'
谁能
这样的事情应该做到:
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