import Foundation
let pattern = #"\[[^\]]+\]\(([^)]+)\)$"#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"""
ARMSTRONG, Gary. 2000. Football Hooligans: Knowing the Score. Oxford: Berg.
[ANONYMOUS 2018] [The authors(s)]. 2018. Personal interview with a police officer from the Criminal Police and Investigation Service. July 26.
[BLESK] 2011. Za vstup na trávník vězení? [A prison for entering the lawn?]. Blesk, May 27.
[BLESK] 2014a. Galerie idiotů. [Gallery of idiots]. Blesk, March 26.
[BLESK] 2014b. Obvinili chuligány! [They accused the hooligans!]. Blesk, April 16.
CDK. 2003. Exploze fotbalového chuligánství, nebo mediální hysterie? Analýza Centra strategických studií [Explosion of football hooliganism or media hysteria? Analysis of the Center for Strategic Studies]. CDK.cz, [https://www.cdk.cz/explozefotbaloveho-chuliganstvi-nebo-medialni-hysterie](https://www.cdk.cz/explozefotbaloveho-chuliganstvi-nebo-medialni-hysterie)
ČERMÁK, David. 2013. Odvolaný gól, žalování ve škole. Tak vznikla rivalita pražských "S". [Goal disallowed, school sued. This is how the rivalry between Prague's "S" was born.]. iDNES.cz, November 15. [https://www.idnes.cz/fotbal/prvni-liga/serial-120-let-sparty-jak-vznikla-rivalita-prazskych-s.A131115092119fotbalpar](https://www.idnes.cz/fotbal/prvni-liga/serial-120-let-sparty-jak-vznikla-rivalita-prazskych-s.A131115092119fotbalpar)
CRABBE, Tim. 2003. "The Public Gets what the Public Wants:" England Football Fans, "Truth" Claims and Mediated Realities. International Review for the Sociology of Sport 38 (4): 413-425. [https://doi.org/10.1177/1012690203384003](https://doi.org/10.1177/1012690203384003)
CRAWFORD, Garry. 2004. Consuming Sport: Fans, Sport and Culture. London: Routledge. [https://doi.org/10.4324/9780203493922](https://doi.org/10.4324/9780203493922)
DIVIŠOVÁ, Vendula. 2019. Rehabilitation or risk aversion? Banning supporters from sporting events in the Czech Republic. Sport in Society 22(12): 2224-2242. [https://doi.org/10.1080/17430437.2019.1568411](https://doi.org/10.1080/17430437.2019.1568411)
DUKE, Vic & Pavel SLEPIČKA. 2002. Bohemian rhapsody: Football supporters in the Czech Republic. In Fighting fans: Football hooliganism as a world phenomenon, ed. Eric Dunning, 49-61. Dublin: University College Dublin Press.
FILIP, Martin. 2003. Lubas: Asi čekáme až na mrtvé [Mr. Lubas: We're probably waiting for the dead ones]. Lidové noviny, May 21.
GARLAND, David. 2001. The Culture of Control: Crime and Social Order in Contemporary Society. Chicago: University of Chicago Press. [https://doi.org/10.7208/chicago/9780226190174.001.0001](https://doi.org/10.7208/chicago/9780226190174.001.0001)
GIULIANOTTI, Richard & Gary ARMSTRONG. 1995. Ungentlemanly Conduct: Football Hooligans, the Media and the Construction of Notoriety. In Crime and the media: The post-modern spectacle, eds. David Kidd-Hewitt & Richard Osborne. London: Pluto Press.
HALL, Stuart. 1978. The Treatment of "Football Hooliganism" in the Press. In Football Hooliganism: The Wider Context, ed. Roger Ingham, 15-36. London: Inter-Action Imprint.
HALL, Stuart, Charles CRITCHER, Tony JEFFERSON, John CLARKE & Brian ROBERTS. 1978. Policing the Crisis: Mugging, the State, and Law and Order. London: Macmillan. [https://doi.org/10.1007/978-1-349-15881-2](https://doi.org/10.1007/978-1-349-15881-2)
HORKY, Thomas. 2016. Contents and patterns of construction of sports coverage in the press. Results from a cross-national comparative study. European Journal for Sport and Society 7(3-4): 265-282. [https://doi.org/10.1080/16138171.2010.11687862](https://doi.org/10.1080/16138171.2010.11687862)
JAKOUBEK, Jiří. 2002. Na konci tunelu nevidím světýlko [I can't see the little light at the end of the tunnel]. Lidové noviny, April 8.
KOPŘIVA, Ondřej. 2013. O slušném fandění [About decent cheering.]. Lidové noviny, July 17.
KREJČA, Pavel, Tomáš KONÍČEK & Ondřej MICHÁLEK. 2012. Zakažte jim fotbal! NAVŽDY! [Ban them from football! FOREVER!]. Blesk, February 21.
KUBITA, Jan. 2004. Poslanci: Výtržníci nesmějí na fotbal [MPs: Rioters are not allowed at football.]. Lidové noviny, June 25.
MELNICK, Merrill J. 1986. The Mythology of Football Hooliganism: A Closer Look at the British Experience. International Review for the Sociology of Sport 21(1): 1-19. [https://doi.org/10.1177/101269028602100101](https://doi.org/10.1177/101269028602100101)
MURPHY, Patrick, Eric DUNNING & John WILLIAMS. 1988. Soccer Crowd Disorder and the Press: Processes of Amplification and De-amplification in Historical Perspective. Theory, Culture and Society 5: 645-673. [https://doi.org/10.1177/026327](https://doi.org/10.1177/026327) 688005004003
NENADÁL, Adam. 2009. Česko čeká na svůj Brusel [The Czechia is waiting for its Brussels.]. Lidové noviny, March 19.
PEARSON, Geoff. 1998. The English Disease? The Socio-Legal Construction of "Football Hooliganism." Youth and Policy 60: 1-15.
PETRÁK, Michal. 2010. Kde hledat kořeny nenávisti mezi Baníkem a Spartou? [Where to look for the roots of hatred between Baník and Sparta?]. iSport.cz, May 2, [https://isport.blesk.cz/clanek/fotbal-gambrinus-liga-rocnik-09-10/90503/kdehledat-koreny-nenavisti-mezi-banikem-a-spartou.html](https://isport.blesk.cz/clanek/fotbal-gambrinus-liga-rocnik-09-10/90503/kdehledat-koreny-nenavisti-mezi-banikem-a-spartou.html)
POULTON, Emma. 2005. English Media Representation of Football-related Disorder: "Brutal, Short-hand and Simplifying"? Sport in Society 8(1): 27-47. [https://doi.or](https://doi.or/) g/10.1080/1743043052000316605
POULTON, Emma. 2006. "Lights, Camera, Aggro!": Readings of "Celluloid Hooliganism." Sport in Society 9(3): 403-426. [https://doi.org/10.1080/17430430600673431](https://doi.org/10.1080/17430430600673431)
POULTON, Emma. 2007. "Fantasy football hooliganism" in popular media. Media, Culture & Society 29(1): 151-164. [https://doi.org/10.1177/0163443706072003](https://doi.org/10.1177/0163443706072003)
POULTON, Emma. 2008. Toward a cultural sociology of the consumption of "fantasy football hooliganism." Sociology of Sport Journal 25(3): 331-349. [https://doi.org/10](https://doi.org/10). 1123/ssj.25.3.331
POULTON, Emma. 2013. The culture of production behind the (re)production of football hooligan culture. Continuum 27(6): 770-784. [https://doi.org/10.1080/10304312.2013.794195](https://doi.org/10.1080/10304312.2013.794195)
POULTON, Emma. 2014. The Hooligan Film Factory: Football Violence in High Definition. In Football Hooliganism, Fan Behaviour and Crime: Contemporary Issues, eds. Matt Hopkins & James Treadwell, 154-175. Basingstoke: Palgrave Macmillan. [https://doi.org/10.1057/97811373479788](https://doi.org/10.1057/97811373479788)
PROCHÁZKA, Pavel. 2022. Jak vznikla zášť mezi Spartou a Baníkem Ostrava? A proč shořela tribuna v Bradfordu? [How did the grudge between Sparta and Baník Ostrava arise? And why did the tribune burn down in Bradford?]. eFotbal.cz, April 4. [https://www.efotbal.cz/clanek-227396-Jak-vznikla-zast-mezi-Spartou-a-Banikem-Ost](https://www.efotbal.cz/clanek-227396-Jak-vznikla-zast-mezi-Spartou-a-Banikem-Ost) rava-A-proc-shorela-tribuna-v-Bradfordu.html
SMOLÍK, Josef. 2012. Football Hooligans in the Czech Republic: Selected Topics. Kultura Społeczeństwo – Edukacja [Poznań: Adam Mickiewicz University Press] 2: 75-95. [https://doi.org/10.14746/kse.2012.2.07](https://doi.org/10.14746/kse.2012.2.07)
STOTT, Cliff & Geoff PEARSON. 2007. Football "Hooliganism", Policing and the War on the "English Disease." London: Pennant Books.
SUCHAN, Ondřej. 2012. Je otázkou času, kdy se stane tragédie [It's only a matter of time before tragedy strikes.]. Lidové noviny, February 25.
TSOUKALA, Anastassia. 2006. Constructing the Threat in a Sports Context. British Press Discourses on Football Hooliganism. In Violence and Sport, ed. Jose Aquesolo, 372-379. Seville: University Pablo de Olavide. [https://www.cafyd.com/HistDeporte/htm/](https://www.cafyd.com/HistDeporte/htm/) pdf/4-18.pdf
TSOUKALA, Anastassia. 2008. Boundary-creating Processes and the Social Construction of Threat. Alternatives: Global, Local, Political 33: 137-152. [https://doi.org/10.1177/03](https://doi.org/10.1177/03) 0437540803300202
TSOUKALA, Anastassia. 2009. Football Hooliganism in Europe. Security and Civil Liberties in the Balance. New York: Palgrave Macmillan [https://doi.org/10.1057/9780230594661](https://doi.org/10.1057/9780230594661)
TSOUKALA, Anastassia. 2011. Timing "dangerousness": Football crowd disorder in the Italian and Greek press. Sport in Society 14(5): 598-611. [https://doi.org/10.1080/17](https://doi.org/10.1080/17) 430437.2011.574360
TSOUKALA, Anastassia, Geoff PEARSON & Peter T. M. COENEN, eds. 2016. Legal Responses to Football "Hooliganism" in Europe. The Hague: T.M.C. ASSER PRESS. [https://doi.org/10.1007/978-94-6265-108-1](https://doi.org/10.1007/978-94-6265-108-1)
UNIE VYDAVATELŮ. 2017. Tisková zpráva Unie vydavatelů 10. srpna 2017 [Union of Publishers Press Release August 10, 2017.]. Median.eu, [https://www.median.eu/cs](https://www.median.eu/cs) /wp-content/uploads/docs/MP201712Qzprava.pdf
VANĚK, Jakub. 2019. Slezské derby, více než jen fotbalové utkání. Jak vznikla rivalita v ochozech? [Silesian derby, more than just a football match. How did the rivalry in the corridors come about?]. Česká televize, August 2. [https://sport.ceskatelevize](https://sport.ceskatelevize/). cz/clanek/fotbal/1-liga/slezske-derby-vice-nez-jen-fotbalove-utkani-jak-vznikla-riv alita-v-ochozech/5d431b97fccd259ea4c34af4
VOCHOCOVÁ, Lenka. 2007. Třetí poločas fotbaloví chuligáni v ČR a násilí [The third half football hooligans in the Czech Republic and violence]. Rexter.cz, November 1, [www.rexter.cz/treti-polocas---fotbalovi-chuligani-v-cr-a-nasili/2007/11/01/](http://www.rexter.cz/treti-polocas---fotbalovi-chuligani-v-cr-a-nasili/2007/11/01/)
WAITON, Stuart. 2014. Football Fans in an Age of Intolerance. In Football Hooliganism, Fan Behaviour and Crime. Contemporary Issues, eds. Matt Hopkins & James Treadwell, 201-221. Basingstoke: Palgrave Macmillan. [https://doi.org/10.1057/978113734797810](https://doi.org/10.1057/978113734797810)
WHANNEL, Garry. 1979. Football Crowd Behaviour and the Press. Media, Culture and Society 1(4): 327-42. [https://doi.org/10.1177/016344377900100402](https://doi.org/10.1177/016344377900100402)
YOUNG, Kevin & Michael D. SMITH. 1988. Mass media treatment of violence in sports and its effects. Current Psychology 7(4): 298-311. [https://doi.org/10.1007/BF02686627](https://doi.org/10.1007/BF02686627)
ZÁKRAVSKÝ, Jiří. 2016. Sport a mezinárodní vztahy. Sportovní diplomacie jako součást zahraniční politiky [Sport and International Relations. Sports Diplomacy as a Part of Foreign Policy]. Central European Journal of Politics 2(2): 15-36.
ZVĚŘINA, Martin. 2004. Fotbal, zákon a pan Ostrý [Football, the law and Mr. Ostrý.]. Lidové noviny, May 18.
"""#
let stringRange = NSRange(location: 0, length: testString.utf16.count)
let matches = regex.matches(in: testString, range: stringRange)
var result: [[String]] = []
for match in matches {
var groups: [String] = []
for rangeIndex in 1 ..< match.numberOfRanges {
let nsRange = match.range(at: rangeIndex)
guard !NSEqualRanges(nsRange, NSMakeRange(NSNotFound, 0)) else { continue }
let string = (testString as NSString).substring(with: nsRange)
groups.append(string)
}
if !groups.isEmpty {
result.append(groups)
}
}
print(result)
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 Swift 5.2, please visit: https://developer.apple.com/documentation/foundation/nsregularexpression