The Greatest Regex Trick Ever (2014)
Let me take these PhD level regex down to elementary school awesome.<p>I have a process table and I want to grep it for the phrase "banana":<p>ps auxww | grep banana<p>root  87  Jun21   0:26.78 /System/Library/CoreServices/FruitProcessor --core=banana<p>mikec 456 450PM   0:00.00 grep banana<p>Argh! It also greps for the grep for banana! Annoying!<p>Well, I'm sure there's pgrep or some clever thing, but my coworker showed me this and it took me a few minutes to realize how it works:<p>ps auxww | grep [b]anana<p>root  87  Jun21   0:26.78 /System/Library/CoreServices/FruitProcessor --core=banana<p>Doc Brown spoke to me: "You're just not thinking fourth dimensionally!" Like Marty, I have a real problem with that. But don't you see: [b]anana matches banana but it doesn't match 'grep [b]anana' as a raw string. And so I get only the process I wanted!