正则表达式将一个var放入另一个的正则表达式的值

时间:2012-12-18 19:41:30

标签: c#

如何将我的var userId放到regexp?

string userId = "ololoawd";

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

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

您没有指定您期望作为输出的内容。我只能看到你在连接userId之前没有正确终止你的第一个字符串。请尝试以下方法:

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