I need a regular expression that just separates the opening square bracket[ and closing square bracket ] from the following string
String
[{"some_id":"1"},{"some_id":"3"},{"some_id":"5"},{"some_id":"7"}]
I need a regular expression that just separates the opening square bracket[ and closing square bracket ] from the following string
String
[{"some_id":"1"},{"some_id":"3"},{"some_id":"5"},{"some_id":"7"}]
Using regex:
import re
re.search("\[(.*)\]", my_str).group(1)
String methods:
my_str.rstrip("]").lstrip("[")
Converting to Python dict (since it's a valid JSON):
import json
json.loads(my_str)