Java Regular Expression – Part 1

Watch here:



Regular Expression

1. If we want to represent a group of a string according to a particular pattern then we should go for Regular Expression.
e.g. We can write a regular expression to represent all valid mobiles.
e.g. We can write a regular expression to represent all email ids.
2. The main important application areas of regular expressions are a. To develop validation frameworks e.g. email
b. To develop pattern matching applications (control+f in windows, grep in Unix)
c. To develop translators like assemblers, compilers, interpreters etc
Compiler design phases
2.a Lexical Analysis -> Syntax Analysis -> Semantic Analysis -> Intermediate Code Generation (I.C.G) -> Code optimisation (CO) -> Target Code Generation
Lexical Analysis = Tokenization (Scanner). (Implemented based on RE)
Syntax – Parsing
d. To develop digital circuits.
e. To develop communication protocols like TCP/IP, UDP etc

3. A Pattern object is a compiled version of a regular expression, that is, it is a java equivalent object of the pattern. We can create pattern object using compile method of pattern class.
4. We can use Matcher object to check the given pattern in the target string. We can matcher object using matcher method of Pattern class.

Contact us at online.nimit@gmail.com

Leave a Reply

Your email address will not be published. Required fields are marked *