I need to parse a message (git commit message) and retrieve some information from there (ID's for main chapters). This messages not respect a pattern on main chapters position (Eg. Features is not always before defects).
Note: Any main chapter ("Features:","Some_random_text:" or other "string:") can exist or not in the message. If exists , retrieve ID and label (Eg. "Features:" )
Expected output: "Features: 4554773, 4554773", if exists
In the rows below you can find a message example:
Some text here
Features:
- ID: 4554773
- ID: 23423234
Some_random_text:
- another stuff here
- ID: 2255444
=========
Another info here
Where I fail is extracting ID's for "Features:" and ID'S for "Some_random_text:".
Programming language used: Python3.X
My existing code:
def get_features(commit_message):
try:
my_result=commit_message.split("Features:")[1]
except IndexError:
return("-")
result=my_result.split("ID:")[1].split()[0].split("\n")[0]
return (result)
Any help will be appreciated.