Saturday 6 January 2018

1. Introduction to Regular Expressions (RegEx)

1. What is a Regular expression?
  1. Regular expression (or in short regex) is a very useful tool that is used to describe a search pattern for matching the text. 
  2. Regex is nothing but a sequence of some characters that defines a search pattern. 
  3. Regex is used for parsing, filtering, validating, and extracting meaningful information from large text, such as logs and output generated from other programs.
  4. For example, while searching for your favorite recipe on search engines, while filling up forms and entering data such as username and passwords, and so on. While setting up a password on many sites, we encounter password validation errors, such as password must contain one digit or at least one uppercase letter or at least one special character, and so on. 


 2. History of Regular expression?
  1. Mathematician Stephen Kleene built a model in the year 1956 using finite automata for simple algebra.
  2. He described regular languages using his mathematical notation called regular sets. 
  3. Computer programmers started using regular expressions in the 1970s when the Unix operating system 
  4. Regular expressions gained more popularity with the arrival of Perl and Tcl scripting languages in the 1980s and 1990s. 
  5. Since then, all the popular programming languages, such as Java, Python, Ruby, R, PHP, and .NET have built very good support of regular expressions.
  6. All the programming and scripting languages have built-in support for regular expressions these days. 
  7. The basic rules to define and execute regular expressions are pretty much the same across all the languages. 


 3. What type of problems need regular expressions to solve
  1. Some programmers wonder why they even need to learn regular expressions. Here are some use cases:
  2. Searching for a MAC address in a log message, searching for IP address in a web server access log, or searching for a 10-digit mobile number that may be optionally preceded by 0 or +<2 digit country code>
  3. Sometimes, we need to split a given text on delimiters of a variable type and length and generate tokens.

3. Java Program to create Binary Tree