问题
I'm trying to find LF characters that appear between double quotes. The text file I'm searching has field-value pairs in this format
msgid "text 1"
msgstr "text 2"
I'm trying to find if LF characters appear within text 1 or text 2 strings. I have tried "[^"\r\n]*\n[^"\r\n]*"
but it just picks up " msgstr "
回答1:
This regex :
if ($subject =~ m/"([^"\r\n]*?[\r\n]+[^"\r\n]*?)"\s*$/m) {
$result = $1;
}
When applied to these strings :
msgid "text 1 "
msgstr "text 2"
msgstr "something with new
line"
Will produce this output :
something with new
line
来源:https://stackoverflow.com/questions/7740435/regex-matching-eol-character-within-a-string