JAVA REGEX用于在一行内的双引号中查找字符串(JAVA REGEX to find strings in double quotes that are within a line)

编程入门 行业动态 更新时间:2024-10-22 17:17:48
JAVA REGEX用于在一行内的双引号中查找字符串(JAVA REGEX to find strings in double quotes that are within a line)

我试图在一行内给出一个文本文件来查找双引号内的字符串。 我有这个正则表达式 \"([^\"]*)\" ,这可以正常工作,但对于我的场景,请确定具有双引号的字符串,从一行开始,到另一行结束。例如,

"test "

上面的例子是两个。 所以它不应该打印。 请帮助我使用正则表达式来识别一行中双引号的字符串

I am trying to find the strings inside double quotes given a text file within a line. I have this regex \"([^\"]*)\" which works fine. But for my scenario identify the strings that have the double quote starting in one line and ending in other line. for example,

"test "

the above example is in two. so it should not print that. Please help me with a regex that identify strings in double quotes within a line

最满意答案

在引号之间从接受的字符中排除行分隔符\r \n 。 试试\"([^\"\n\r]*)\"

Exclude line separators \r \n from accepted characters between quotes. Try with \"([^\"\n\r]*)\"

更多推荐

本文发布于:2023-08-07 21:10:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465590.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   双引号   JAVA   REGEX   find

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!