C# regexp将一个变量放入另一个变量的regexp值中

C# regexp将一个变量放入另一个变量的regexp值中,c#,C#,如何将我的var userId放入regexp string userId = "ololoawd"; string did = Regex.Match(content, @"""dID"":""(.*?)"",""dOF"":true,""dOID"":"" + userId + "",""usS"":").Groups[1].Value; 您没有指定预期的输出。我所能看到的是,在将userId连接到中之前,没有正确终止第一个字符串。请尝试以下操作: string userId = "ol

如何将我的var userId放入regexp

string userId = "ololoawd";

string did = Regex.Match(content, @"""dID"":""(.*?)"",""dOF"":true,""dOID"":"" + userId + "",""usS"":").Groups[1].Value;

您没有指定预期的输出。我所能看到的是,在将userId连接到中之前,没有正确终止第一个字符串。请尝试以下操作:

string userId = "ololoawd";
string did = Regex.Match(content, @"""dID"":""(.*?)"",""dOF"":true,""dOID"":""" + userId + @""",""usS"":").Groups[1].Value;
string userId = "ololoawd";
string did = Regex.Match(content, @"""dID"":""(.*?)"",""dOF"":true,""dOID"":""" + userId + @""",""usS"":").Groups[1].Value;