20 lines
1.1 KiB
Plaintext
20 lines
1.1 KiB
Plaintext
# by Artyom Bologov
|
|
H
|
|
,p
|
|
# Join all the lines
|
|
g/./s/$/|/
|
|
,j
|
|
s/^/|/
|
|
# Replace the patterns starting from the possibly longest
|
|
g/|/s/^.*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*|.*\1.*\2.*\3.*\4.*\5.*\6.*\7.*\8.*\9.*|$/\1\2\3\4\5\6\7\8\9/
|
|
g/|/s/^.*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*|.*\1.*\2.*\3.*\4.*\5.*\6.*\7.*\8.*|$/\1\2\3\4\5\6\7\8/
|
|
g/|/s/^.*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*|.*\1.*\2.*\3.*\4.*\5.*\6.*\7.*|$/\1\2\3\4\5\6\7/
|
|
g/|/s/^.*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*|.*\1.*\2.*\3.*\4.*\5.*\6.*|$/\1\2\3\4\5\6/
|
|
g/|/s/^.*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*|.*\1.*\2.*\3.*\4.*\5.*|$/\1\2\3\4\5/
|
|
g/|/s/^.*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*|.*\1.*\2.*\3.*\4.*|$/\1\2\3\4/
|
|
g/|/s/^.*\(.\{1,\}\).*\(.\{1,\}\).*\(.\{1,\}\).*|.*\1.*\2.*\3.*|$/\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