Step up your Regex game
Tags: javascript, regex, beginners, devjournal
Published: 2020-12-25 00:15:38

>Learning Regex (Regular Expressions) is not fun or easy at first, but it is a beyond important skill when strategizing solving problems with strings. Here is a brief overview on ways to best learn regex, tutorials on regex, and cheat sheets.

---
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/r96w4h2zbgzglrh01pm0.jpg)
---

When I first saw **Regex** I immediately said what the heck is this!? I knew right off the bat it required some time and concentration to get it right and wrote it off as a “I’ll try this later” kind of deal. I kept pushing it off and thought, hey I’ll just code my way out of problems, no big deal. Was I ever wrong! In one of my most recent technical interviews, guess what? Regex came up!

Regex is very important, not only for solving problems that manipulate strings, but are widely used in text-editors, to search for data, filtering results, matching passwords, matching emails, validating forms, etc. You can go from solving a string manipulation problem on **CodeWars** or **HackerRank** in _n_ time to cutting that time in half with Regex! This goes to show you how valuable Regex really is!

So began my process to understanding **Regex** completely. I don’t want to strive to just solving problems by brute force, but rather I’d like to be efficient as possible. Hence the quote, “think smarter not harder”.

Below I felt are the best ways to obtain that **Regex** knowledge, going from beginner to intermediate, and well advanced? If you want to be advanced you need to practice Regex on the reg, and if you set your mind to it you will achieve it.

##First Steps:
You understand you need to learn Regex but where do you start??

### Step 1 — Take a tutorial:

_Well praise God for **DuckDuckGo** (I only use DuckDuckGo) and Google, here are some pretty cool sites that offer a step-by-step learning process that will surely help. I like the fact that a few of these offer quizzes at the end._

1. **RegexOne** —  [https://regexone.com/](https://regexone.com/)
2. **Learn Regex** — [https://learn-regex.com/](https://learn-regex.com/)
3. **RegularExpressions.Info Tutorial** —  [https://www.regular-expressions.info/tutorial.html](https://www.regular-expressions.info/tutorial.html)
4. **Mozilla Regular Expressions** (Use this to see how to code with Regex for beginners) — [https://www.regular-expressions.info/tutorial.html](https://www.regular-expressions.info/tutorial.html)
5. **W3Schools JS Regex Tutorial** —  [https://www.w3schools.com/jsref/jsref_obj_regexp.asp](https://www.w3schools.com/jsref/jsref_obj_regexp.asp)
6. **Javascript.info Regular Expressions** — [https://javascript.info/regular-expressions](https://javascript.info/regular-expressions)

### Step 2 — Practice on **CodeWars** or **HackerRank**:

Definitely start immediately on using Regex to solve problems when strings are present. The best place to do this is to go to **CodeWars** and **HackerRank** and start from the beginning. Whenever I start learning something new or need to refresh, I create a new account on these and start from the beginning and I always learn something new coding.

_Another thing to note is it helps to solve these problems first on something familiar and helpful to you uniquely. I often create a new Repl.it and solve the problem there, then paste the solution in the HackerRank or CodeWars editor to solve. Just drag some of the arrays or data their using for the initial tests and run your solution on them. There are other online code editors such as JS Bin, PlayCode, or JS Fiddle that work great as well._

Here are a few sample problems that should be simple enough to use Regex on:

1. **CodeWars** — _Your order, please_: [https://www.codewars.com/kata/your-order-please]( https://www.codewars.com/kata/your-order-please)
2. **CodeWars** — _Jaden Casing_:  [https://www.codewars.com/kata/5390bac347d09b7da40006f6]( https://www.codewars.com/kata/5390bac347d09b7da40006f6)
3. **CodeWars** — _Collection of Strings_ (problems involving strings)_:  [https://preview.codewars.com/collections/strings-130]( https://preview.codewars.com/collections/strings-130)
4. **HackerRank** — _Solve Regex (list of Regex Problems)_:  [https://www.hackerrank.com/domains/regex](https://www.hackerrank.com/domains/regex)

### Step 3 (optional) — Find videos on YouTube, Udemy, or other sites:
If you want to be good at something and you need a visual kick or walk through just look up some videos to help follow along. This is just a suggestion and everyone has their own unique preference for people they like to follow along with. Get busy and do some searching!

## Second Steps:

You’ve learned the regex basics but where to go from here? Start your own projects immediately! The only way to really learn and commit those things to memory is straight up creating or building some projects yourself with 0 help from tutorials or anyone else. This is the only way to learn.

Here are some ideas for first projects:

1. **Create a Regex Matcher** — create a project where you can test a regex on a string, highlighting the exact matches on the string with the regex you provided. Give a simple “Success!” or “Failed” somewhere based on strings you’re evaluating to match.
2. **Create a search filter bar**: return only data sets that match the input given of a string. An example of this would be **Netflix** or **DisneyPlus**. Return only the videos that match or similar to what you are searching for in the search bar. There are a million ways to come up with your own version of this.

## Useful Tools:

Keep practicing Regex. Here are some useful tools and cheat sheets to promote your growth!

### Cheat Sheets:
Use these when referencing Regex on the go when using in your own projects and **CodeWars** or **HackerRank**:

1. **Regex Tutorial** — _A quick cheat sheet by example by Johnny Fox_:  [https://medium.com/factory-mind/regex-tutorial-a-simple-cheatsheet-by-examples-649dc1c3f285](https://medium.com/factory-mind/regex-tutorial-a-simple-cheatsheet-by-examples-649dc1c3f285)
2. **Ultimate Regex Cheatsheet** — [https://www.keycdn.com/support/regex-cheatsheet](https://www.keycdn.com/support/regex-cheatsheet)

### Practicing your Regex:

Use these Regex engines to practice on. Will come in handy for writing out your Regex before you drop it into code when learning.

1. **Regexr.com** — [https://regexr.com/](https://regexr.com/)
2. **Regex101.com** — [https://regex101.com/](https://regex101.com/)

I hope you were able to get some value out of everything in this article. Just know that if you are struggling in programming or coding, there is always a solution and you can do it. No matter what never give up and keep growing. Everyone is unique, and the way you learn is to, you just have to make it fun and adapt to what works for you!

If you are someone who's worked with **Regex** before or have some knowledge on the subject, I have a few questions for you! What sites helped you grow/learn with **Regex**? What projects did you work on that helped as well?  Please share below in the comments because I'd definitely like to know and I'm sure others would to!

**Bless**