如何将我的 var userId 放入正则表达式?
string userId = "ololoawd";
string did = Regex.Match(content, @"""dID"":""(.*?)"",""dOF"":true,""dOID"":"" + userId + "",""usS"":").Groups[1].Value;
如何将我的 var userId 放入正则表达式?
string userId = "ololoawd";
string did = Regex.Match(content, @"""dID"":""(.*?)"",""dOF"":true,""dOID"":"" + userId + "",""usS"":").Groups[1].Value;
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;