在使用re 正则匹配处理文本数据时,可能是由于正则写的不严谨问题,导致在匹配过程中会遇到程序卡死情况(PS:有知道这个为什么会出现卡死的大佬请多多指教),如下:
input_str = r'mathrm{OH}\overset{\mathrm{浓H}_2\mathrm{SO}_4}{\underset\bigtriangleup\rightleftarrows}CH_{3}=CO'
split_ch = []
def repl(m):
split_ch.append(m.group(0))
split_ch.append(m.group(1))
split_ch