70 likes | 185 Views
This article explores the realm of regular expressions (REX) and their role in defining various types of regular languages. It discusses essential concepts such as concatenation, union, and closure, as well as practical applications such as validating strings for specific patterns, including passwords. We delve into the formal definitions of REX, how they can generate deterministic finite automata (DFA), and provide examples of language definitions. Learn how to check for substrings and find first occurrences in strings, making REX a powerful tool in programming and data validation.
E N D
Types of Regular Languages Must contain a substring Must contain certain symbols Concatenation Union Closure (*) Parity
Uses of Regular Language Validation of strings such as passwords. Checking for existence of substring. Finding first occurrence of substring. Pattern matching
Regular Expressions (REX) String notation to define patterns Any regular language can be expressed as a regular expression and vice versa. Given REX can generate DFA
Formal Definition e is a regular expression (REX) over if e is • λ, • , • a, for some a Σ, • (e1 + e2), where e1 and e2 are REXs over , • (e1 . e2), where e1 and e2 are REXs over , or • (e1*), where e1 and e2 are REXs over .
Examples (Defined over {0,1}*) • L1={w | w contains substring 01} • L2={w | |w| is even} • L3={w | |w| is odd} • L4={w | w starts and ends with 1}