Like regular expressions to get the same dictionaries?

while parsing I need to get with the token dictionaries
var onMapMarkers=[
 {'id':'7','name':'"HookahPlace Samara". Address: Chapaevskaya str., 187, Samara, Samara region, Russia, 443010','url':'http://smr.hookahplace.ru/smr','lat':'53.198277','lng':'50.102364'},
 {'id':'8','name':'"HookahPlace Ufa". Address: Karla Marksa, 30, Ufa, Republic of Bashkortostan, Russia Of Bashkortostan, Russia, 450015','url':'http://ufa.hookahplace.ru/ufa','lat':'54.730873','lng':'55.944843'},
 {'id':'9','name':'"HookahPlace Sochi." Address: Moskovskaya St., 25, Sochi, Krasnodar Krai, Russia, 354000','url':'http://sochi.hookahplace.ru/sochi','lat':'43.593937','lng':'39.722965'},
 {'id':'10','name':'"HookahPlace Voronezh". Address: Moskovskiy prosp., 155g, Voronezh, Voronezh region, Russia, 394018','url':'http://vrn.hookahplace.ru/vrn','lat':'51.74550777','lng':'39.18299336'},
 {'id':'11','name':'"Hookahplace Kazan Volkova". Address: ul. Volkova, 70, Kazan, Rep. Republic of Tatarstan, Russia, 420043','url':'http://kzn.hookahplace.ru/kzn','lat':'55.78773629163424','lng':'49.14401384788516'},
 {'id':'12','name':'"HookahPlace Lubyanka". Address: Myasnitskaya St., 24/7 C1, Moscow, Russia, 101000','url':'http://msk.hookahplace.ru/lubyanka','lat':'55.76260097','lng':'37.63561129'},
 {'id':'13','name':'"HookahPlace Nizhny Novgorod". Address: Illinska str., 43B, Nizhny Novgorod, Nizhny Novgorod region, Russia, 603000','url':'http://nn.hookahplace.ru/nn','lat':'56.323208944120736','lng':'43.990732009925864'},
 {'id':'14','name':'"HookahPlace Ryazan". Address: Gorkogo, 92, Ryazan, Ryazan region, Russia, 390000','url':'http://rzn.hookahplace.ru/rzn','lat':'54.62638133771338','lng':'39.74223424785043'},
 {'id':'15','name':'"HookahPlace Tula". Address: Lenina street, 61, Tula, Tula region, Russia, 300012','url':'http://tula.hookahplace.ru/tula','lat':'54.182770','lng':'37.606640'},
 {'id':'16','name':'"HookahPlace Novorossiysk". Address: Lenina, 4, Novorossiysk, Krasnodarskiy Kray, Russia, 353905','url':'http://nvrsk.hookahplace.ru/nvrsk','lat':'44.704948','lng':'37.784954'},
 {'id':'17','name':'"Novosibirsk". Address: Yadrintsevskaya str., 18, Novosibirsk, Novosibirsk region, Russia, 630099','url':'http://nsk.hookahplace.ru/nsk','lat':'55.0331861384834','lng':'82.92470240555724'},
 {'id':'19','name':'"HookahPlace Bryansk". Address: Lenina 39, Bryansk, Bryansk region, Russia, 241044','url':'http://brsk.hookahplace.ru/brsk','lat':'53.244221','lng':'34.364140'},
 {'id':'20','name':'"HookahPlace Krasnodar Babushkina". Address: Babushkina str., 218, Krasnodar, Krasnodar Krai, Russia, 350049','url':'http://krsndr.hookahplace.ru/krsndr','lat':'45.047981','lng':'38.965385'},
 {'id':'21','name':'"HookahPlace Tyumen". Address: Lenina St., 2, Tyumen, Tyumen region, Russia, 625003','url':'http://tmn.hookahplace.ru/tmn','lat':'57.163197','lng':'65.519287'},
 {'id':'22','name':'"HookahPlace Ekaterinburg". Address: vainera str., 40, Yekaterinburg, Sverdlovsk region, Russia, 620014','url':'http://ekb.hookahplace.ru/ekb','lat':'56.831512','lng':'60.595547'},
 {'id':'23','name':'"HookahPlace Kaliningrad". Address: Proletarskaya St., 82, Kaliningrad, Kaliningrad oblast, Russia, 236021','url':'http://kgd.hookahplace.ru/kgd','lat':'54.71946242855139','lng':'20.514114083328195'},
 {'id':'24','name':'"HookahPlace Krasnoyarsk." Address: Dubrovinskogo St., 43/2, Krasnoyarsk, Krasnoyarsk Krai, Russia, 660017','url':'http://krsk.hookahplace.ru/krsk','lat':'56.005556','lng':'92.853003'},
 {'id':'25','name':'"HookahPlace Irkutsk". Address: St. Friedrich Engels 8, Irkutsk, Irkutsk region, Russia, 664007','url':'http://irk.hookahplace.ru/irk','lat':'52.284817','lng':'104.304550'},
 {'id':'26','name':'"HookahPlace Mytischi". Address: Olympic Avenue, 13кБс1, Mytishchi, Moscow region, Russia, 141006','url':'http://mt.hookahplace.ru/mt','lat':'55.919666','lng':'37.762985'},
 {'id':'27','name':'"HookahPlace Perm". Address: Sovetskaya str., 46, Perm','url':'http://perm.hookahplace.ru/perm','lat':'58.015115','lng':'56.238587'},
 {'id':'29','name':'"HookahPlace Home Rostov-on-don". Address: Greek pereulok, 11, Rostov-on-don, Rostov region, Russia, 344022','url':'http://rnd.hookahplace.ru/rnd','lat':'47.22663238552845','lng':'39.72924827249142'},]


I have to get the dictionaries. how to get one - I got it
\[\s*({.+})
second, to get just to finish the first version of \[\s*({.+}),\s*({.+})

but in dictionaries there are many, if any way to get one dictionary and a regular expression something like a loop
March 23rd 20 at 19:05
2 answers
March 23rd 20 at 19:07
Uh, it's json
To deserialize and run as normal dict
March 23rd 20 at 19:09
spoiler
import ast
import re

text = r"'
var onMapMarkers=[
 {'id':'7','name':'"HookahPlace Samara". Address: Chapaevskaya str., 187, Samara, Samara region, Russia, 443010','url':'http://smr.hookahplace.ru/smr','lat':'53.198277','lng':'50.102364'},
 {'id':'8','name':'"HookahPlace Ufa". Address: Karla Marksa, 30, Ufa, Republic of Bashkortostan, Russia Of Bashkortostan, Russia, 450015','url':'http://ufa.hookahplace.ru/ufa','lat':'54.730873','lng':'55.944843'},
 {'id':'9','name':'"HookahPlace Sochi." Address: Moskovskaya St., 25, Sochi, Krasnodar Krai, Russia, 354000','url':'http://sochi.hookahplace.ru/sochi','lat':'43.593937','lng':'39.722965'},
 {'id':'10','name':'"HookahPlace Voronezh". Address: Moskovskiy prosp., 155g, Voronezh, Voronezh region, Russia, 394018','url':'http://vrn.hookahplace.ru/vrn','lat':'51.74550777','lng':'39.18299336'},
 {'id':'11','name':'"Hookahplace Kazan Volkova". Address: ul. Volkova, 70, Kazan, Rep. Republic of Tatarstan, Russia, 420043','url':'http://kzn.hookahplace.ru/kzn','lat':'55.78773629163424','lng':'49.14401384788516'},
 {'id':'12','name':'"HookahPlace Lubyanka". Address: Myasnitskaya St., 24/7 C1, Moscow, Russia, 101000','url':'http://msk.hookahplace.ru/lubyanka','lat':'55.76260097','lng':'37.63561129'},
 {'id':'13','name':'"HookahPlace Nizhny Novgorod". Address: Illinska str., 43B, Nizhny Novgorod, Nizhny Novgorod region, Russia, 603000','url':'http://nn.hookahplace.ru/nn','lat':'56.323208944120736','lng':'43.990732009925864'},
 {'id':'14','name':'"HookahPlace Ryazan". Address: Gorkogo, 92, Ryazan, Ryazan region, Russia, 390000','url':'http://rzn.hookahplace.ru/rzn','lat':'54.62638133771338','lng':'39.74223424785043'},
 {'id':'15','name':'"HookahPlace Tula". Address: Lenina street, 61, Tula, Tula region, Russia, 300012','url':'http://tula.hookahplace.ru/tula','lat':'54.182770','lng':'37.606640'},
 {'id':'16','name':'"HookahPlace Novorossiysk". Address: Lenina, 4, Novorossiysk, Krasnodarskiy Kray, Russia, 353905','url':'http://nvrsk.hookahplace.ru/nvrsk','lat':'44.704948','lng':'37.784954'},
 {'id':'17','name':'"Novosibirsk". Address: Yadrintsevskaya str., 18, Novosibirsk, Novosibirsk region, Russia, 630099','url':'http://nsk.hookahplace.ru/nsk','lat':'55.0331861384834','lng':'82.92470240555724'},
 {'id':'19','name':'"HookahPlace Bryansk". Address: Lenina 39, Bryansk, Bryansk region, Russia, 241044','url':'http://brsk.hookahplace.ru/brsk','lat':'53.244221','lng':'34.364140'},
 {'id':'20','name':'"HookahPlace Krasnodar Babushkina". Address: Babushkina str., 218, Krasnodar, Krasnodar Krai, Russia, 350049','url':'http://krsndr.hookahplace.ru/krsndr','lat':'45.047981','lng':'38.965385'},
 {'id':'21','name':'"HookahPlace Tyumen". Address: Lenina St., 2, Tyumen, Tyumen region, Russia, 625003','url':'http://tmn.hookahplace.ru/tmn','lat':'57.163197','lng':'65.519287'},
 {'id':'22','name':'"HookahPlace Ekaterinburg". Address: vainera str., 40, Yekaterinburg, Sverdlovsk region, Russia, 620014','url':'http://ekb.hookahplace.ru/ekb','lat':'56.831512','lng':'60.595547'},
 {'id':'23','name':'"HookahPlace Kaliningrad". Address: Proletarskaya St., 82, Kaliningrad, Kaliningrad oblast, Russia, 236021','url':'http://kgd.hookahplace.ru/kgd','lat':'54.71946242855139','lng':'20.514114083328195'},
 {'id':'24','name':'"HookahPlace Krasnoyarsk." Address: Dubrovinskogo St., 43/2, Krasnoyarsk, Krasnoyarsk Krai, Russia, 660017','url':'http://krsk.hookahplace.ru/krsk','lat':'56.005556','lng':'92.853003'},
 {'id':'25','name':'"HookahPlace Irkutsk". Address: St. Friedrich Engels 8, Irkutsk, Irkutsk region, Russia, 664007','url':'http://irk.hookahplace.ru/irk','lat':'52.284817','lng':'104.304550'},
 {'id':'26','name':'"HookahPlace Mytischi". Address: Olympic Avenue, 13кБс1, Mytishchi, Moscow region, Russia, 141006','url':'http://mt.hookahplace.ru/mt','lat':'55.919666','lng':'37.762985'},
 {'id':'27','name':'"HookahPlace Perm". Address: Sovetskaya str., 46, Perm','url':'http://perm.hookahplace.ru/perm','lat':'58.015115','lng':'56.238587'},
 {'id':'29','name':'"HookahPlace Home Rostov-on-don". Address: Greek pereulok, 11, Rostov-on-don, Rostov region, Russia, 344022','url':'http://rnd.hookahplace.ru/rnd','lat':'47.22663238552845','lng':'39.72924827249142'},]
"'

a = ast.literal_eval(re.search('(?s)var onMapMarkers=(\[.*?\])', text).group(1))

for in a shop:
 print(shop['name'])

Find more questions by tags Regular expressionsParsingPython