$ BAZ="\"DON'T PANIC\" in large, friendly letters"The double quote analog of the single quote regex looks like "[^"]*", but that won't handle the escaped quotes. A regex of \\" will, but only once. To combine these regex, I use the same approach as before, moving the * from the first regex to the combined regex, and weighting the regex to prefer \\". The combined regex is "(\\"|[^"])*".
echo $BAZ
"DON'T PANIC" in large, friendly letters
$ cat in
BAZ="\"DON'T PANIC\" in large, friendly letters"
$ perl -ne 'print "$&\n" if m/"(\\"|[^"])*"/' in
"\"DON'T PANIC\" in large, friendly letters"
Notice, this doesn't match the key portion of the variable line. I'll address that in the next post.
No comments:
Post a Comment