您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

C#正则表达式,单引号之间的字符串

C#正则表达式,单引号之间的字符串

这样的事情应该做到:

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
c# 2022/1/1 18:20:00 有447人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶