我怎样才能匹配所有字符?
例如,我如何匹配 regex.match 中的每个可能的字符。
string value4 = (",\"message\":\"all characters\",");
Match[] message = Regex.Matches(docText, @value4)
匹配
,"message":"all characters here",
与我尝试过的
string value4 = (",\"message\":\".\",");
string value4 = (",\"message\":\"[.]\",");
string value4 = (",\"message\":\"[.*]\",");
string value4 = (",\"message\":\".*\",");
,但没有一个起作用。
编辑:
我与 ,"message":"allcharactershere",
匹配的值可以在“allcharactershere”部分中包含任何字符,我想匹配 < 的所有实例code>,"message":"这里的所有字符", 忽略第二组引号之间的内容
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不希望值中出现任何引号,则可以使用:
写为
"\"message\":\"([^\"]*)\""
- 作为常规字符串文字@"""message"":""([^""]*)"""
作为 逐字字符串)如果您已转义引号,则一个选项是这样,它也允许所有转义字符:
写为:
"\"message\":\"(([^\"\\\\]|\\ \\.)*)\""
@"""消息"":""(([^""\\]|\\.)*)"""
If you don't expect any quotes in your value, you can use:
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:
Written as:
"\"message\":\"(([^\"\\\\]|\\\\.)*)\""
@"""message"":""(([^""\\]|\\.)*)"""