import re
regex = re.compile(r"^(.*)(\r?\n\1)+$", flags=re.MULTILINE)
test_str = ("{\"??\", \"What?\"}\n"
"{\"0mg\", \"Oh My God\"},\n"
"{\"0wn\", \"owned\"},\n"
"{\"10\\\\/3u\", \"love you\"},\n"
"{\"13wt\", \"Loot\"},\n"
"{\"2\", \"too\"},\n"
"{\"31337\", \"elite\"},\n"
"{\"4tw\", \"for the win\"},\n"
"{\"A&D\", \"Attack and Defend\"},\n"
"{\"AFAIK\", \"As Far As I Know\"},\n"
"{\"AFK\", \"Away from keyboard\"},\n"
"{\"ASL\", \"Age Sex Location\"},\n"
"{\"ATM\", \"At The Moment\"},\n"
"{\"BAF\", \"Bring A Friend\"},\n"
"{\"BBIM\", \"Be Back In a Minute\"},\n"
"{\"BBL\", \"Be Back Later\"},\n"
"{\"BBS\", \"Be Back Soon\"},\n"
"{\"BFG\", \"big fucking gun\"},\n"
"{\"BRB\", \"Be Right Back\"},\n"
"{\"BS\", \"Bullshit\"},\n"
"{\"BTW\", \"By The Way\"},\n"
"{\"Camper\", \"Ambush\"},\n"
"{\"CFT\", \"Capture the flag\"},\n"
"{\"CTF\", \"Capture the Flag\"},\n"
"{\"CU\", \"See You\"},\n"
"{\"d00d\", \"Dude\"},\n"
"{\"DM\", \"Death Match\"},\n"
"{\"DMG\", \"Damage\"},\n"
"{\"dog8\", \"dog\"},\n"
"{\"duma**\", \"idiot\"},\n"
"{\"eet\", \"elite\"},\n"
"{\"em\", \"Them\"},\n"
"{\"exp\", \"experience points\"},\n"
"{\"EXP\", \"Experience Points\"},\n"
"{\"f00\", \"Fool\"},\n"
"{\"FAQ\", \"Frequently Asked Questions\"},\n"
"{\"FB\", \"Flash Bang grenade\"},\n"
"{\"FFA\", \"Free For All\"},\n"
"{\"FFS\", \"For Fuck's Sake\"},\n"
"{\"FH\", \"Full Health\"},\n"
"{\"Flak\", \"Debris\"},\n"
"{\"Flame\", \"Nonstop insulting\"},\n"
"{\"form\", \"from\"},\n"
"{\"FPS\", \"First Person Shooter\"},\n"
"{\"fragged\", \"killed\"},\n"
"{\"ftw\", \"for the win\"},\n"
"{\"G2G\", \"Got To Go\"},\n"
"{\"GA\", \"Go Ahead\"},\n"
"{\"GD\", \"God Damn\"},\n"
"{\"GF\", \"Good Fight\"},\n"
"{\"GG\", \"Good Game\"},\n"
"{\"GGA\", \"Good Game All\"},\n"
"{\"gimme\", \"Give me\"},\n"
"{\"GL\", \"Good Luck\"},\n"
"{\"Going Gold\", \"publishing of software\"},\n"
"{\"grill\", \"girl\"},\n"
"{\"guise\", \"guys\"},\n"
"{\"h@\", \"Hat\"},\n"
"{\"h4x\", \"hacks\"},\n"
"{\"h4x0r\", \"hacker\"},\n"
"{\"h8\", \"Hate\"},\n"
"{\"hai\", \"hi\"},\n"
"{\"high-ping bastard\", \"crappy internet\"},\n"
"{\"HP\", \"Health Points\"},\n"
"{\"IIRC\", \"If I Recall Correctly\"},\n"
"{\"IMHO\", \"In My Honest Opinion\"},\n"
"{\"IMO\", \"In My Opinion\"},\n"
"{\"instagib\", \"unlimited ammo\"},\n"
"{\"IRC\", \"Internet Relay Chat\"},\n"
"{\"IRL\", \"In Real Life\"},\n"
"{\"j0\", \"Yo!\"},\n"
"{\"J00\", \"You!\"},\n"
"{\"JJ\", \"Just Joking\"},\n"
"{\"JK\", \"Just Kidding\"},\n"
"{\"kewl\", \"cool\"},\n"
"{\"kicked\", \"banned cheater\"},\n"
"{\"kk\", \"ok\"},\n"
"{\"KOS\", \"Kill On Sight\"},\n"
"{\"l@ym\", \"laughing at your momma\"},\n"
"{\"l337\", \"elite\"},\n"
"{\"l33t\", \"Elite\"},\n"
"{\"l4m3r\", \"lamer\"},\n"
"{\"level up\", \"Improving\"},\n"
"{\"liek\", \"like\"},\n"
"{\"lobby\", \"chat room\"},\n"
"{\"LOL\", \"Laughs out loud\"},\n"
"{\"lopl\", \"lol\"},\n"
"{\"low-ping bastard\", \"fast internet\"},\n"
"{\"Lvl\", \"Level\"},\n"
"{\"m2\", \"me too\"},\n"
"{\"m8\", \"mate\"},\n"
"{\"Mana\", \"cast magical spells\"},\n"
"{\"mastah\", \"master\"},\n"
"{\"max0r\", \"max\"},\n"
"{\"Med\", \"Medic\"},\n"
"{\"meh\", \"oh well\"},\n"
"{\"MMORPG\", \"Massive Multiplayer Online Role Playing Game\"},\n"
"{\"Mod\", \"A modification of a game\"},\n"
"{\"MP\", \"Multiplayer\"},\n"
"{\"MTFBWY\", \"May The Force Be With You\"},\n"
"{\"n00b\", \"newbie\"},\n"
"{\"N1\", \"Nice one\"},\n"
"{\"Nade\", \"Grenade\"},\n"
"{\"nd\", \"and\"},\n"
"{\"Nerfed\", \"bad bug\"},\n"
"{\"newb\", \"newcomer\"},\n"
"{\"nooblet\", \"newcomer\"},\n"
"{\"np\", \"No problem\"},\n"
"{\"NT\", \"nice try\"},\n"
"{\"OLO\", \"LOL\"},\n"
"{\"OMDG\", \"oh my dance\"},\n"
"{\"OMFG\", \"Oh My Fucking God\"},\n"
"{\"OMG\", \"oh my god\"},\n"
"{\"OMGWTFBBQ\", \"Oh My God What The Fuck Barbecue\"},\n"
"{\"OMW\", \"On My Way\"},\n"
"{\"OOR\", \"Out Of Range\"},\n"
"{\"OOS\", \"Out Of Sight\"},\n"
"{\"ORLY\", \"Oh, really?\"},\n"
"{\"ORLY\", \"Oh, really?\"},\n"
"{\"OSOK\", \"One Shot One Kill\"},\n"
"{\"own\", \"own\"},\n"
"{\"ownage\", \"superior\"},\n"
"{\"p0wn\", \"pawned\"},\n"
"{\"ph33r\", \"Fear me\"},\n"
"{\"phear\", \"fear\"},\n"
"{\"PITA\", \"Pain In The Arse/Ass\"},\n"
"{\"PK\", \"Player Killing\"},\n"
"{\"pl0x\", \"please\"},\n"
"{\"PMGZ\", \"OMG\"},\n"
"{\"PMSL\", \"Pissing MySelf Laughing\"},\n"
"{\"Polishing\", \"final touches\"},\n"
"{\"Port\", \"Teleport\"},\n"
"{\"powwah\", \"power\"},\n"
"{\"Pr0n\", \"porn\"},\n"
"{\"pwnage\", \"superior\"},\n"
"{\"pwnt\", \"superior\"},\n"
"{\"r\", \"are\"},\n"
"{\"r0x0r\", \"dude that rocks!\"},\n"
"{\"rgr\", \"Roger\"},\n"
"{\"ROFL\", \"Rolls on the floor laughing\"},\n"
"{\"ROFLMAO\", \"Rolling On the Floor Laughing My Ass Off\"},\n"
"{\"rox\", \"Rocks\"},\n"
"{\"RP\", \"Role Play\"},\n"
"{\"RPG\", \"Role-Playing Game\"},\n"
"{\"RT\", \"Roger That\"},\n"
"{\"RTFM\", \"Read the f***ing manual\"},\n"
"{\"RTS\", \"Real-Time Strategy\"},\n"
"{\"Sig\", \"Signature\"},\n"
"{\"sk1llz\", \"Skills\"},\n"
"{\"Slug\", \"A large, non-self-propelled projectile\"},\n"
"{\"smat\", \"smart\"},\n"
"{\"SP\", \"Single Player\"},\n"
"{\"Spam\", \"Repeatedly messaging the same messages\"},\n"
"{\"spawn\", \"reborn\"},\n"
"{\"sry\", \"Sorry\"},\n"
"{\"STFU\", \"Shut The Fuck UP\"},\n"
"{\"sup\", \"What's Up\"},\n"
"{\"sux0r\", \"Sucks\"},\n"
"{\"taunt\", \"Provoking\"},\n"
"{\"TBH\", \"To Be Honest\"},\n"
"{\"teh\", \"the\"},\n"
"{\"Thx\", \"Thanks\"},\n"
"{\"TPS\", \"Third Person Shooter\"},\n"
"{\"Ty\", \"Thank you\"},\n"
"{\"u\", \"you\"},\n"
"{\"w8\", \"wait\"},\n"
"{\"wat\", \"what\"},\n"
"{\"WB\", \"Welcome Back\"},\n"
"{\"wen\", \"when\"},\n"
"{\"whut\", \"what\"},\n"
"{\"winnar\", \"winner\"},\n"
"{\"wot\", \"what\"},\n"
"{\"WTF\", \"What the f***?\"},\n"
"{\"WTG\", \"Way To Go\"},\n"
"{\"WYG\", \"What You Got?\"},\n"
"{\"y\", \"why\"},\n"
"{\"ya\", \"yeah\"},\n"
"{\"yass\", \"yes\"},\n"
"{\"yea\", \"yeah\"},\n"
"{\"yos\", \"yes\"},\n"
"{\"yus\", \"yes\"},\n"
"{\"ZPMG\", \"OMG\"},")
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
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