No votes yet.
Please wait...

Interaction with regular expression is not easy. Nobody is really happy to analyze ^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$ and try to find out what this really means.

But still, regular expressions are a very powerful tool and it’s recommended to understand the way they work, even if you are not an expert in this field.

This article is a useful introduction to the world of regular expressions. If you meet them while performing software testing, you will feel confident and technically free.

Regular expressions are simply a consequence of certain symbols that define a template for seeking something.

They can be used for editing the lines of software code and also, for testing the correspondence between a phone number, date, postal code, and an established template.

You should also know that they are easier to operate when you have good testing software in your hands. In our case, it’s Regex software.

Further, we’ll analyze 10 most popular symbols of regular expressions that can be met every day while performing software testing. And it’s Regex that will help us to interpret this.

RegEx Logo

RegEx Logo

1 ^

A special symbol “caret” indicates that a user wishes to find matches with the beginning of a certain word.

For example, if a user uses a template ^foot, he/she will get matches with such words as ^football, ^footstep.

2 $

This dollar symbol means that a user wishes to find a match with the end of a certain word.

The pattern that ends with ball$, can find the word football but can’t find the word balloon since this word doesn’t begin with the part ball.

3 .

A special symbol of a full stop indicates a match with a special symbol. It can be used when one of the special symbols varies.

The pattern foo.ball can find football and also foosball.

4 *

A special symbol of an asterisk indicates that a special symbol can/should match once or several times.

In our pattern fo*tball, a letter “O” can coincide one or several times.

This pattern can find football, fotball and foooootball.

5 \d

\d (backslash and d) indicates searching for a match with any suggested number.

Our pattern football\d can easily match with football1, football2 and so on but it won’t match with football or football!

6 ()

Double brackets are responsible for grouping a pattern, in the same way as mathematical expressions.

Let’s imagine that we would like to find December or November but not January. If we have no possibility to use pattern “ember”, it will simply match with all current months. But we can operate (Dec|Nov)ember — using brackets with a horizontal line means that the month we are searching for can begin with Dec or Nov and should end with ember.

Conclusion

The topic of regular expressions is a very interesting field that beckons us but can make us lost in it.

Junior specialists should “play” with Regex software to not only practice but also, learn the basics of working with regular expressions.

Leave A Comment