Description
- Given a datafile where each line may contains one or more
\cite{...}s.
- Each \cite{...} may contain one or more members
separated by commas. For example,
\cite{AA}, \cite{BB,CC}
- We want to prepend `xx_' before each member of every \cite{...}.
- There may be some brace-enclosed structures other than \cite{...}s in a line.
|
| Raw Input
|
| Desired Output
| ..\cite{AA}....
...\cite{BB}...\mbox{CC}...\cite{DD}....
........
.....\cite{EE,FF}....\em{GG}....
......\cite{HH,II}.....\cite{JJ,KK,LL}....
....\cite{MM}...\mbox{NN}...\cite{OO,PP}....\cite{QQ}...
|
| ..\cite{xx_AA}....
...\cite{xx_BB}...\mbox{CC}...\cite{xx_DD}....
........
.....\cite{xx_EE,xx_FF}....\em{GG}....
......\cite{xx_HH,xx_II}.....\cite{xx_JJ,xx_KK,xx_LL}....
....\cite{xx_MM}...\mbox{NN}...\cite{xx_OO,xx_PP}....\cite{xx_QQ}...
|
|
Script and Comments
Script1 [ 1] s/\\cite\{/&\n/g
[ 2] /\n/!b
[ 3] :loop
[ 4] s/\n([^,}]*[,}])/xx_\1\n/g
[ 5] s/\}\n/}/g
[ 6] /\n/b loop
| |