问题
I have to remove the bugging unnecessary tags in a document like:
{\sffamily FOOBARFOOOBAR
FOOBAR
FOO \bf{FOOBAR}
FOOBAR
}
into
FOOBARFOOOBAR
FOOBAR
FOO \bf{FOOBAR}
FOOBAR
I used to be able to do this with html tags like
{\sffamily \d } replacing with \1
but i cannot make it work with tex tags..
Anyone any advices?
回答1:
I can give you a regex for your example - you weren't far off with your initial attempt - but I'm not sure it'll help with your overall problem.
Find:
\{\\sffamily ((?:.*\r*\n*)*?)\}
Replace:
\1
WARNING: You will run into problems if the tags you're replacing are nested. But, I don't think there's going to be a way around that using regex without some serious headaches. You would be better off with a small script here.
回答2:
Use detex, which strips TeX from a source file.
来源:https://stackoverflow.com/questions/12236132/how-to-remove-latex-tags-using-regex