Re: reg exp question
On Wed, Oct 20, 1999 at 10:56:12AM +0100, Oliver Elphick wrote:
> Shao Zhang wrote:
> >Hi,
> > I have very limited reg exp knowledge, but I need this badly...
> >
> > Could someone tell me how to write a sed script to replace the
> > following string?
> >
> > From string \textsc{Foo} to Foo
> >
> > Thanks for your help.
>
> sed -e 's/\\textsc{\(.*\)}/\1/'
This goes wrong if you have two of these expressions on one line:
\textsc{Foo} \textsc{Bar}
gives
Foo} \textsc{Bar
If `Foo' cannot contain any `}' characters, then you can solve this with
sed -e 's/\\textsc{\([^}]*\)}/\1/g'
If `Foo' does contain `}' (like \textsc{\Foo{\Bar}}) then I don't know
how to handle that.
If this really is TeX, you could probably add
\def\textsc#1{#1}
somewhere at the top of your document to get the desired result.
HTH,
Eric
--
E.L. Meijer (tgakem@chem.tue.nl)
Eindhoven Univ. of Technology
Lab. for Catalysis and Inorg. Chem. (SKA)
Reply to: