Skip to content

Commit c6f7589

Browse files
committed
Added common.remove_numeric_parentheses()
1 parent a8af049 commit c6f7589

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

t3/common.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import datetime
66
import os
7+
import re
78
import string
89
from typing import Dict, List, Optional, Tuple, Union
910

@@ -373,3 +374,17 @@ def get_o2_stoichiometry(smiles: Optional[str] = None,
373374
if other:
374375
raise ValueError(f'Cannot calculate O2 stoichiometry for {fuel.label} with {other} atoms which are not C/H/N/O.')
375376
return 0.5 * (2 * c + 0.5 * h - o)
377+
378+
379+
def remove_numeric_parentheses(input_string: str) -> str:
380+
"""
381+
Remove numeric parentheses from the end of a string.
382+
383+
Args:
384+
input_string (str): The input string.
385+
386+
Returns:
387+
str: The string without numeric parentheses.
388+
"""
389+
result = re.sub(r'\(\d+\)$', '', input_string)
390+
return result

0 commit comments

Comments
 (0)