I have many tex files containing something like \chapter{ccc}
, \section{sss}
, etc. I want to change them to markdown format like # ccc
, ## sss
, etc.; my minimal demo is as follows:
\chapter{math}
mmm
\section{opt}
ooo
\section{prob}
ppp
\section{stat}
sss
\subsection{biostat}
bbb
\chapter{phys}
yyy
\chapter{chem}
ccc
Take section
for example, I tried
Find: \\section(\{.*?\})
Replace: ## $1
while the braces {}
are still there. How can solve this problem? Or are there any more efficient ways can get there?
You can simply change the match group from outside (\{.*?\})
to inside the curly braces \{(.*?)\}
:
Find: \\section\{(.*?)\}
Replace: ## $1
Now the the match group $1
only contain the text opt
, prob
, etc.. inside the curly braces. The results:
\chapter{math}
mmm
## opt
ooo
## prob
ppp
## stat
sss
\subsection{biostat}
bbb
\chapter{phys}
yyy
\chapter{chem}
ccc