DEV Community

Syed Faateh Sultan Kazmi
Syed Faateh Sultan Kazmi

Posted on

How powerful are the regular expressions for faster coding

Do you know about a technique that can speed up your coding experience for almost all the code editors in the world?

Code Editors, the long debate 😁

Choosing a code editor is a long (and never-ending) debate though. The choice of code editor totally depends on your needs as well as your comfort. There is no perfect for all code editor. The one that you prefer, may not be a good option for someone else. So, explore multiple code editors to find your favorite one. (Remember, I'm talking about code editors, not IDEs πŸ˜‘). Some of the top trending GUI code editors today are:

Also, there are some CLI code editors like Vim and Nano.

But all GUI editors have one common feature!

Regular Expressions in Code Editors

Most of the time, especially when modifying a previously written code. We all use Find (CTRL+F) and Replace (CTRL+H) features to search a previously coded module, features, variable, or method. Although this feature is very good, Regular Expressions can increase their productivity up to a great extent.

Usage of RE in Code Editors

I personally use the Visual Studio Code. So, I'll illustrate 3 very basic examples of using regular expressions to search for specific content in the codebase.
*Note that you must turn on RE feature as shown in the image below:
RE Demo 0

1. Match any single character (except a line break)

RE Demo 1
can match any sequence such as cms, crm, or c3s etc.

2. Match multiple characters

RE Demo 2
can match any sequence such as cases, comes, c43s etc.

3. Match at the beginning of a sentence

Alt Text
can match all the lines starting with user.

There are many more ways to use Regular Expressions for searching the codebase.

You can find Regular Expression usage in Visual Studio Code and Visual Studio IDE. If you are using some other editor, google its docs!

Hope you like this! πŸ˜‰

Top comments (2)

Collapse
 
delta456 profile image
Swastik Baranwal

Thanks

Collapse
 
faatehsultan profile image
Syed Faateh Sultan Kazmi

My Pleasure :)