70 likes | 177 Views
Regular Expressions. 1. 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.
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}