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]*)\"

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]*)\"