How to remove latex tags using regex?

大兔子大兔子 提交于 2019-12-12 00:29:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!