Tags: python
Rating:
With help of regex `,\+\+\+.+?,` we replace anything between `,+++` and `,` with empty space `''`.
Then we construct a dict by evaluating its string representaion with `literal_eval()` . From there it's easy to get any data we want.
```python
import re
import json
import ast
def ParseNamesByGroup(blob, group_name):
c = re.sub(r',\+\+\+.+?,', ',', blob)
match = re.findall(r'(?<=\[).+?(?=\])', c)
match = ["{%s}" % (i) for i in match]
dictlist = []
for i in match:
res = ast.literal_eval(i)
dictlist.append(res)
result = []
for d in dictlist:
if d["Group"] == group_name:
result.append(d["user_name"])
return result
data = raw_input()
group_name = data.split('|')[0]
blob = data.split('|')[1]
result_names_list = ParseNamesByGroup(blob, group_name)
print result_names_list
```