'How to truncate text in this format?

I'm trying to extract from this list

[<JIRA Issue: key='HDDIS-42214', id='855344'>,
 <JIRA Issue: key='HDDIS-42171', id='854930'>,
 <JIRA Issue: key='HDDIS-42170', id='854929'>]

the 3 strings:

HDDIS-42214
HDDIS-42171
HDDIS-42170

How can do this?

PS: At some point it can be 3, another 1, another 2...



Solution 1:[1]

if your text is a list convert it to string using:

my_string = ','.join(your_list)

Below is python code

text = "[<JIRA Issue: key='HDDIS-42214', id='855344'>, <JIRA Issue: key='HDDIS-42171', id='854930'>, <JIRA Issue: key='HDDIS-42170', id='854929'>]"
import re    
m = re.findall("(?<=<)(.*?)(?=>)",text)
res = list()
for i in m:
   key = re.findall("(?<=key=')(.*?)(?=',)",i)
   res.append(key[0])

Your output would be: enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1