RegEx匹配具有1个或更多结果的报价 [英] RegEx match quotes with 1 or more results
本文介绍了RegEx匹配具有1个或更多结果的报价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写与以下内容匹配的RegEx
I'm trying to write a RegEx that matches the following
"Field1":"Any Content"
但不是这个
"Field1":""
我尝试过
"Field1":".*?"
但它找到与"匹配的内容
But it finds matches for ""
感谢您的帮助.
推荐答案
尝试将零个或多个量词( *
)更改为一个或多个量词( +
):
Try changing your zero-or-more quantifier (*
) to a one-or-more quantifier (+
):
"Field1":".+?"
您可能还想考虑使用字符类,如下所示:
You may also want to consider using a character class, like this:
"Field1":"[^"]+"
这篇关于RegEx匹配具有1个或更多结果的报价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文