开发者

How can i match all characters?

How can i match every possible character in regex.match for example.

string value4 = (",\"message\":\"all characters\",");
Match[] message = Regex.Matches(docText, @value4)

matched against

,"message":"all characters here",

I have tried

string value4 = (",\"message\"开发者_开发问答:\".\","); 

string value4 = (",\"message\":\"[.]\","); 

string value4 = (",\"message\":\"[.*]\",");

string value4 = (",\"message\":\".*\",");

and none of them worked.

Edit:

the value that i'm matching against ,"message":"all characters here", can have any characters in the "all characters here" section, I would like to match all instances of ,"message":"all characters here", ignoring what is in between the second set of quotes


If you don't expect any quotes in your value, you can use:

"message":"([^"]*)"

Which is written as

  • "\"message\":\"([^\"]*)\"" - as a regular string literal
  • @"""message"":""([^""]*)""" as a Verbatim String)

If you have escaped quotes, one option is this, which also allows all escaped characters:

"message":"(([^"\\]|\\.)*)"

Written as:

  • "\"message\":\"(([^\"\\\\]|\\\\.)*)\""
  • @"""message"":""(([^""\\]|\\.)*)"""
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜