如何在Regex中的引号中获得带有引号内部值的所有值?
我试图使用正则表达式获取引号中的每个值,在某些情况下我得到它,而在其他情况下我没有。
我的正则表达式:/(?:-reason|-r) ?"(.+?)(?:"-|" -|"?$\B)/g
下面是我测试过的一些句子,第 1 行和第 2 行与正则表达式匹配,但第 3 行不匹配。
1 anything -reason "some reason" -anyArg "anything"
2 anything -reason "Hello World, you're the "best"" -anyArg "anything"
3 anything -r "anything "here" is wrong" anything
图像的最后一句与正则表达式不兼容,我该怎么做才能使正则表达式全部匹配?
I'm trying to get every value in quotes using regex, in some situations I get it and others I don't.
My Regex: /(?:-reason|-r) ?"(.+?)(?:"-|" -|"?$\B)/g
Below are some sentences I've been testing, line 1 and 2 match regex, but line 3 doesn't.
1 anything -reason "some reason" -anyArg "anything"
2 anything -reason "Hello World, you're the "best"" -anyArg "anything"
3 anything -r "anything "here" is wrong" anything
The last sentence of the image is not compatible with the regex, what do I do to make the regex match them all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
请参见 Regex Prace 。
解释
Use
See regex proof.
EXPLANATION