Noob’s Guide to Regexes

I remember the first time I saw a regex I was like:

This is because they look like gibberish:

\S[A-Q].?[a-q]?\S

But actually they are just fancy find and replace methods! So if you had a statement like this:

“I do not understand regexes. Please help.”

The above regex would find: “I do”

How Regexes Work:

Essentially the regex statement just looks for a pattern, with these characters : / /

And different characters mean different things. That’s it! Really!

I’m serious though. Regexes are doable.

I just got a copy of The Bastards Book of Regexes, and here is a sampling of some things I’ve encountered so far:

Commonly used characters:

\b : Means a word bounday Like the space at the beginning or end of the word!
\bI : Means at the beginning of a word there is the letter I
"Okay I'm starting to get Regexes. Info is seeping into my brain. I hope this ends well.
*Note - The backslash only affects the character after it

And if the word boundary referred to the end of a word:

/is\b/ : Means the letters "is" followed by a space:
"Okay I'm starting to get Regexes. Info is seeping into my brain. I hope this ends well. And I hope I don't forget anything. Ever."

Now what if you wanted to find a number?

\d - Means a digit
"It is 10 pm and I need to get up at 6 am. Why am I poking around Github?"

This is just a surface overview, there’s a lot more to learn about regexes, though!

Here are some more resources:

Regex Cheat Sheet : A bunch of common regexes! — https://www.cheatography.com/davechild/cheat-sheets/regular-expressions/

Rubular.com: to enter in regexes and see what text is highlighted — http://rubular.com/

The Bastards Books of Regular Expressions: a textbook for regexes! — http://regex.bastardsbook.com/