What is a REGEX?

No, REGEX is not a new type of dinosaur or any of your ex loved ones. REGEX stands for regular expression.

First we need to understand what regular means. Let’s say that common would be a good synonym. Expression in this context is referring to a (fixed) pattern. Easy huh?

Let me explain with a little example: say that you want to match all e-mail addresses in a file. What you would do to accomplish this is write an expression like this:

.+@.+\..+

it would match the first and the third e-mail address:

Don’t worry about the expression itself for now, but as you can see in blue, these are the entries that match. Do you have any idea why the 2nd expression does not match?

Yes, indeed. It is not a valid e-mail address.

But where could we use these REGEXes? Well as you can see, you could use it for input validation. When someone is entering this e-mail in a form for example, you could prompt that the e-mailaddress he typed is incorrect.

You could do the same for the password field: password has to include this and that (uppercase, lowercase, number, special character) and prompt the user with what he has done wrong when he choose his password.

In one of the next articles we will look into the basics of working with REGEX but for now you can already use these resources for some practice and some fun quizzes. I can recommend this REGEX course. (This is how I learned REGEXíng).

Have fun and see you soon!

Categories

Latest articles

Latest comments

No comments to show.

All Splunk Posts