开发者

Regex matching EOL character within a string

开发者 https://www.devze.com 2023-04-12 06:44 出处:网络
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

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"
    msg开发者_JAVA百科str "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 "


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号