1
noqwerty 2017-05-03 13:03:56 +08:00
```python
import re x = '[ CH4 ]' regex = re.compile(r'(\[\s?[A-Z].*?)(\d)(\s?\])') print(re.sub(regex, r'\1<sub>\2</sub>\3', x)) # [ CH<sub>4</sub> ] ``` |