-2

如何将我的 var userId 放入正则表达式?

string userId = "ololoawd";

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

2 回答 2

0
string did = Regex.Match(content, @"""dID"":""(.*?)"",""dOF"":true,""dOID"":" + userId + ",""usS"":").Groups[1].Value;
于 2012-12-18T19:45:25.573 回答
0

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

string userId = "ololoawd";
string did = Regex.Match(content, @"""dID"":""(.*?)"",""dOF"":true,""dOID"":""" + userId + @""",""usS"":").Groups[1].Value;
于 2012-12-18T19:48:55.240 回答