language: Python 3 (python-3.2.3)
date: 473 days 8 hours ago
link:
visibility: private
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import re
 
s = '\\(2 \\, e^{\\left(2 \\, x\\right)} \\sin\\left(2 \\, x\\right) + 2 \\, e^{\\left(2 \\, x\\right)} \\cos\\left(2 \\, x\\right)\\)'
 
print(re.sub(r'e\^{\\left\((.*?)\\right\)}', r'e^{\1}', s))
 
try:
   re.sub(r'(?Pe\^{\\left()(?P.*)(?P\\right)})','e\^{\\g}',s)
except Exception as e:
   print(e)
 
print(re.sub(r'e\^{\\left\((.*)\\right\)}', r'e^{\1}',s))