This topic created in 3349 days ago, the information mentioned may be changed or developed.
比如: [ CH4 ] -> [ CH<sub>4</sub>]
1 replies • 2017-05-03 13:03:56 +08:00
 |
|
1
noqwerty May 3, 2017
```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> ] ```
|