Description
Each line of the datafile is a list consisting of
- the name of the list, followed by a colon (`:'),
- members of the list, separated by commas.
- For example, in D:A,F,C,
`A', `F', and `C' are members of a list named `D'.
Now we want to print one per line every member of a list,
followed by the name of the list. Lists without members are discarded.
|
| Raw Input
|
| Desired Output
| D:A,F,C
C:H
F:B,E
B:
E:H
H:
A:G
G:B
|
| A:D
F:D
C:D
H:C
B:F
E:F
H:E
G:A
B:G
|
|
Script and Comments
Script1 [ 1] s/^([^:]+):([^,]+)(,|$)/\2:\1\n\1:/
[ 2] /\n/P
[ 3] D
| |
|