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