Reputation: 259
Suppose I have a string like
{"", "b", "c"}, // we are here
I would like to extract the {"", "b", "c"}
and/or "", "b", "c"
part of it. Is there any simple prescription for it?
Upvotes: 0
Views: 113
Reputation: 78554
You can use regex - re.search
:
import re
s = '{"", "b", "c"}, // we are here'
m = re.search(r'{.*}', s)
print(m.group(0))
#'{"", "b", "c"}'
{.*}
matches every thing within the curly braces and the braces.
Upvotes: 1