# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"\{\s*ADDIN ZOTERO_ITEM.*http\:\/\/zotero\.org\/.*items\/([^\"]*).*\}\s*}"
test_str = ("The current wave of protests formed through the coming together of three elements. <i>First</i>, some students demonstrated on various university campuses (mainly Táchira) for at least two weeks before the big 12 February 2014 protests. They protested against <i>insecurity</i> and Venezuela’s high crime rates. Vivia Sequera from the Christian Science Monitor claims that students at the University of the Andes were initially protesting an attempted rape of a young woman on campus.<a title=\"\" href=\"#_ftn1\">[1]</a>\n\n"
" \n\n"
"some opposition leaders mobilised their supporters and the Venezuelan Student Movement to protest against the government and call for its resignation – prominently <i>Leopoldo López</i>, leader of the centrist party Voluntad Popular (VP, Popular Will), <i>MarÃa Corina Machado</i> of the liberal party Vente Venezuela (Come Venezuela) and <i>Antonio Ledezma</i> of the social democratic party Alianza Bravo Pueblo (Fearless People's Alliance).<a title=\"\" href=\"#_ftn2\">[2]</a> It is sig\n"
"<div><br clear=\"all\" />\n\n"
"<hr align=\"left\" size=\"1\" width=\"33%\" />\n\n"
"<div>\n\n"
"<a title=\"\" href=\"#_ftnref1\">[1]</a> { ADDIN ZOTERO_ITEM CSL_CITATION {\"citationID\":\"klJTkj1B\",\"properties\":{\"formattedCitation\":\"{\\\\rtf Vivia Sequera, \\\\uc0\\\\u8220{}Did Attempted Rape Ignite Venezuela\\\\uc0\\\\u8217{}s National Protests?,\\\\uc0\\\\u8221{} \\\\i Christian Science Monitor\\\\i0{}, February 22, 2014, http://www.csmonitor.com/World/Latest-News-Wires/2014/0222/Did-attempted-rape-ignite-Venezuela-s-national-protests.}\",\"plainCitation\":\"Vivia Sequera, “Did Attempted Rape Ignite Venezuela’s National Protests?,†Christian Science Monitor, February 22, 2014, http://www.csmonitor.com/World/Latest-News-Wires/2014/0222/Did-attempted-rape-ignite-Venezuela-s-national-protests.\"},\"citationItems\":[{\"id\":1080,\"uris\":[\"http://zotero.org/groups/228165/items/U8EBSIQM\"],\"uri\":[\"http://zotero.org/groups/228165/items/U8EBSIQM\"],\"itemData\":{\"id\":1080,\"type\":\"article-magazine\",\"title\":\"Did attempted rape ignite Venezuela's national protests?\",\"container-title\":\"Christian Science Monitor\",\"source\":\"Christian Science Monitor\",\"abstract\":\"Student protests began at the University of the Andes in San Cristobal, Venezuela, after an attempted rape of a college woman. A week later, the protests boiled over into a violent national uprising.\",\"URL\":\"http://www.csmonitor.com/World/Latest-News-Wires/2014/0222/Did-attempted-rape-ignite-Venezuela-s-national-protests\",\"ISSN\":\"0882-7729\",\"author\":[{\"family\":\"Sequera\",\"given\":\"Vivia\"}],\"issued\":{\"date-parts\":[[\"2014\",2,22]]},\"accessed\":{\"date-parts\":[[\"2014\",4,7]]}}}],\"schema\":\"https://github.com/citation-style-language/schema/raw/master/csl-citation.json\"} }\n\n"
"</div>\n"
"<div>\n\n"
"<a title=\"\" href=\"#_ftnref2\">[2]</a> { ADDIN ZOTERO_ITEM CSL_CITATION {\"citationID\":\"4YnaAzSw\",\"properties\":{\"formattedCitation\":\"{\\\\rtf Sara Carolina D\\\\uc0\\\\u237{}az, \\\\uc0\\\\u8220{}Sector de La Oposici\\\\uc0\\\\u243{}n Convoca a Marcha Para El 12 de Febrero,\\\\uc0\\\\u8221{} February 2, 2014, http://www.eluniversal.com/nacional-y-politica/140202/sector-de-la-oposicion-convoca-a-marcha-para-el-12-de-febrero.}\",\"plainCitation\":\"Sara Carolina DÃaz, “Sector de La Oposición Convoca a Marcha Para El 12 de Febrero,†February 2, 2014, http://www.eluniversal.com/nacional-y-politica/140202/sector-de-la-oposicion-convoca-a-marcha-para-el-12-de-febrero.\"},\"citationItems\":[{\"id\":1136,\"uris\":[\"http://zotero.org/groups/228165/items/MTSN6T7J\"],\"uri\":[\"http://zotero.org/groups/228165/items/MTSN6T7J\"],\"itemData\":{\"id\":1136,\"type\":\"post-weblog\",\"title\":\"Sector de la oposición convoca a marcha para el 12 de febrero\",\"abstract\":\"Caracas.- Cientos de personas atendieron el llamado de parte de la dirigencia opositora y de Voluntad Popular en la plaza Brión de ChacaÃto para participar en una asamblea popular con el fin de expresar su opinión sobre la salida posible a la crisis (...)\",\"URL\":\"http://www.eluniversal.com/nacional-y-politica/140202/sector-de-la-oposicion-convoca-a-marcha-para-el-12-de-febrero\",\"author\":[{\"family\":\"DÃaz\",\"given\":\"Sara Carolina\"}],\"issued\":{\"date-parts\":[[\"2014\",2,2]]},\"accessed\":{\"date-parts\":[[\"2014\",4,7]]}}}],\"schema\":\"https://github.com/citation-style-language/schema/raw/master/csl-citation.json\"} }\n\n"
"</div>\n"
"</div>")
matches = re.search(regex, test_str)
if matches:
print ("Match was found at {start}-{end}: {match}".format(start = matches.start(), end = matches.end(), match = matches.group()))
for groupNum in range(0, len(matches.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = matches.start(groupNum), end = matches.end(groupNum), group = matches.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html