我试图在以下模式中提取所有文本(显示为xxxx):
Session["xxxx"]
Run Code Online (Sandbox Code Playgroud)
使用c#
这可能是Request.Querystring["xxxx"]
我试图动态构建表达式.当我这样做,我得到各种关于未转义的字符或没有匹配的问题:(
一个例子可能是:
string patternstart = "Session[";
string patternend = "]";
string regexexpr = @"\\" + patternstart + @"(.*?)\\" + patternend ;
string sText = "Text to be searched containing Session[\"xxxx\"] the result would be xxxx";
MatchCollection matches = Regex.Matches(sText, @regexexpr);
Run Code Online (Sandbox Code Playgroud)
我可以帮助解决这个问题(因为我似乎总是使用RegEx :))
我有一个控制器类,我可以在API上启动Get调用但是当我尝试POST命令时,我得到HTTP/1.1 415不支持的媒体类型
有什么地方我必须允许POST吗?我把[HttpPost]放在方法前面,但没有运气.
public class initController : ApiController
{
// GET api/<controller>
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/<controller>/5
public string Get(int id)
{
return "value";
}
// POST api/<controller>
[HttpPost]
public string Post([FromBody]string value)
{
oTree myT = new oTree();
myT.build(0);
myT.entity.question = value;
return JsonConvert.SerializeObject(myT);
}
// PUT api/<controller>/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/<controller>/5
public void Delete(int id)
{
}
}
Run Code Online (Sandbox Code Playgroud)
Javscript邮政编码:
function gpRequest(service, …
Run Code Online (Sandbox Code Playgroud) 我想在c#中使用以下正则表达式
<asp:(\w+)\s+.*?id="(\w+)"
Run Code Online (Sandbox Code Playgroud)
我似乎无法将其存储为字符串而不会破坏它.
我怎样才能逃避表达并保持其完整性?
谢谢