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//
s/ /\n/g
s/^\(.*\),\(\w*\),\(\w*\)$/\2 \3 \1/gm
x
s/^.*$/& &/gm
x
s/^/#/
s/$/\n/
x
:Y
x
/#$/bX
x
s/$/\n=e/
G
s/=e.*#\(\w* \w*\) .*/\1/
s/\(.*\)\n\(.*\)/\2\n\1\n/
:A
s/^\(\w\+\) \(.*\n\1 \(\w\+\)\b\)\([^#]\)/\3 \2#\4/
tA
:B
s/^\(\w\+\) \(\w\+\)\b\(.*\n\2 \(\w\+\)\b\)\([^#]\)/\1 \4\3#\5/
tB
/^\(\w*\) \1\b/{s//\1 F/;bD}
/^\w\+ \(\w\+\)\b.*\n\1 \1#/{s/^\(\w*\) \w*\b/\1 T/;bD}
s/^\(\w*\) \w*\b/\1 F/
:D
:E
s/^\(\w*\)\( .* \)\w*#/\1\2\1/
tE
s/\n$//
x
s/$/\n=e/
G
s/#\([^\n]*\n\)\(.*\)\n=e\n\w* \(.\).*/\3 \1#\2/
x
s/.*\n//m
bY
:X
s///
s/\n$//

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page