RegEx - Regular Expression - Information Security

Exclusive

Post Top Ad

"Be Aware, Be Secure"

Post Top Ad

"Information Security is everyone's Job"

Monday, November 21, 2022

RegEx - Regular Expression

RegEx stands for Regular Expression. It is a set of characters that allows to search / parse through the text / string or big chunk of data in an advanced way. This provides powerful, efficient and flexible ways to take out something meaningful out of a large text file and can be used to add, remove, isolate or manipulate text / data as desired. These are nothing just the special characters i.e., (\ + ^ - ? and many more) that control the search criteria for advanced search.

 

                                                                             Source: Computerhope


Let’s take a basic analogy – You locate some keywords in a large Text or PDF using CTRL+F keys in search box and get match of those keywords highlighted. RegEx also allows you to do the similar searching mechanism but with the use of those special characters / symbols and the only difference here is that you can tweak and advance your search criteria as per your requirement.

 

We have flags which we add at the end of regex to define the searching limits.

1.       Global – Match all (e.g., This will try to match search criteria within entire file)

2.       Non-Global – (e.g., Match with a certain criteria i.e., within a line (s), multiple lines (m), with no case sensitivity (i), last index (y), all type of characters and glyphs – symbols (u)

a.       Single line

b.       Multi line

c.       Case Insensitive

d.       Sticky

e.       Unicode

 

Please do not treat RegEx as a programming language. This is just a simple add-on utility (i.e., special encoded chars) on top of programming languages which can be used to fulfil a purpose. The concept of regex is in scenes since a long time. This came into public in 1950s discovered and formalized by Mathematician Stephen Cole Kleene.

 

Industry use-cases of regex in web apps / other areas:

1.       Setting up criteria on password complexity controls

2.       Defining certain formats to accept the data or perform input validation i.e., Card Details / Email IDs / Date of birth and many more

3.       Searching data / keywords / events in a large log file

Listing out some useful resources / links which I used to know more on regex. You can see them to know the characters / symbols we need to use to form a regex string syntax.

  

No comments:

Post a Comment

Post Top Ad

"Cyber Security= Expect the UNEXPECTED"