Search
Sat 17 May 2025
title: "Search" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false
import re
data = [
"name['toronto'] = 'One'",
"state['ontario'] = 'Two'",
"country['canada']['ca'] = 'Three'",
"extra['maple'] = 'Four'"
]
REGEX = re.compile(r"\['(?P<word>.*?)'\]")
for line in data:
found = REGEX.search(line)
if found:
print(found.group('word'))
toronto
ontario
canada
maple
Score: 5
Category: regex