skip to main content

Technology

What are Regular Expressions or RegEx?

Posted on January 18, 2017

A Regular Expression or RegEx is a software programming tool used to match strings in text files, excel csv files, network packet data, logfile parsing, cellphone data, twitter feeds, facebook graph data, hadoop applications. As regular expression is a number of words to keep saying over and over again, we normally abbreviate it to RegEx for one rule and RegExes for many rules.

It has a particularly good application in cybersecurity either running on hardware like Next Generation Firewalls or Smart Network Interface Cards or as a software application running on premise servers or in the cloud. Typically, Regular Expressions can be faster and better than using string based matching for the following reasons.

You can think of regular expressions as wildcard lookups but with a greater number of wildcard types. With wildcards you can simply look up all the files in a directory with the filetype of Powerpoint *.ppt or *.pdf or *.txt or *.doc. Regular expressions can do this too. The equivalent regular expression for a textfile is .*\.tx

You can create more powerful matching formats and notation to search for all the email addresses, website addresses, zip codes, addresses, phone numbers, and many more. Typically you can do more in one line of RegEx code than what would take many lines of code to do with string matching.

RegEx is a very powerful matching tool. Most software languages like Perl, PHP, Java, C, C++, C# and Python have Regular expression capability

There are some great online tools to help you create your RegEx rules.

As regular expression is a long way to say it we normally abbreviate it to RegEx for one rule and RegExes for many rules.