Description
- Every double quote of the datafile is numbered except those which
are escaped.
- The job is to replace every odd-numbered double quote with
a single quote,
and every even-numbered double quote with a back quote.
|
| Raw Input
| ....."test1"...."test2
test2"..not.\"...not.\"..."test3
test3"....."test4
test4
test4"...."test5".
|
|
| Desired Output
| .....`test1'....`test2
test2'..not.\"...not.\"...`test3
test3'.....`test4
test4
test4'....`test5'.
|
|
Script and Comments
Script1 [ 1] 1{
[ 2] x
[ 3] s/^/`/
[ 4] x
[ 5] }
[ 6] :loop
[ 7] /\n/!s/^/\n/
[ 8] s/\n(([^\\"]*|\\.)*)"/\1\n"/
[ 9] /\n"/!{
[10] s/\n//
[11] n
[12] b loop
[13] }
[14] G
[15] s/\n"(.*)\n(.)/\2\n\1/
[16] x
[17] y/`'/'`/
[18] x
[19] b loop
| |
|