Apr-18-2017, 02:45 PM
(Apr-18-2017, 03:52 AM)nilamo Wrote: Regular expressions?>>> data = {'link': None, 'sprint': ['com.atlassian.greenhopper.service.sprint.Sprint@123ed5s[rapidViewId=1234,state=CLOSED,name=Sprint_2,startDate=2017-03-29T10:36:54.327-04:00,endDate=2017-04-11T10:36:00.000-04:00,completeDate=2017-04-12T12:25:51.156-04:00,sequence=12345,id=12345]', 'com.atlassian.greenhopper.service.sprint.Sprint@5rd3d5gd[rapidViewId=1234,state=ACTIVE,name=Sprint_3,startDate=2017-04-12T01:34:47.270-04:00,endDate=2017-04-25T01:34:00.000-04:00,completeDate=<null>,sequence=67890,id=67890]'], 'issueType': 'Story', 'key': 'ABCDEF-55555'} >>> sprint = data['sprint'] >>> for item in sprint: ... print(item) ... com.atlassian.greenhopper.service.sprint.Sprint@123ed5s[rapidViewId=1234,state=CLOSED,name=Sprint_2,startDate=2017-03-29T10:36:54.327-04:00,endDate=2017-04-11T10:36:00.000-04:00,completeDate=2017-04-12T12:25:51.156-04:00,sequence=12345,id=12345] com.atlassian.greenhopper.service.sprint.Sprint@5rd3d5gd[rapidViewId=1234,state=ACTIVE,name=Sprint_3,startDate=2017-04-12T01:34:47.270-04:00,endDate=2017-04-25T01:34:00.000-04:00,completeDate=<null>,sequence=67890,id=67890] >>> import re >>> regex = re.compile(r"state=(.+),name=Sprint_[23]") >>> for item in sprint: ... match = regex.search(item) ... if match: ... print(match.groups()[0]) ... else: ... print("no match") ... CLOSED ACTIVE
Thanks a ton, Nilamo. This worked.