Preview

13 Regular Expressions

Satisfactory Essays
Open Document
Open Document
840 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
13 Regular Expressions
Regular Expressions

This ppt is the work by Dr. Costas Busch, used with permission, and available from http://csc.lsu.edu/~busch/courses/theorycomp/fall2008/ 1

Regular Expressions
Regular expressions describe regular languages

Example:

(a  b c) * describes the language

 a, bc *   , a, bc, aa, abc, bca,...
2

Recursive Definition
Primitive regular expressions:  ,  , 
Given regular expressionsr1

r2 and r1  r2 r1 r2 r1 *

Are regular expressions

 r1 
3

Examples
A regular expression:

 a  b c  * (c   )

Not a regular expression:

 a  b 

4

Languages of Regular Expressions

L r 

r
: language of regular expression

Example

L (a  b c) *   , a, bc, aa, abc, bca,...

5

Definition
For primitive regular expressions:
L   
L     
L a   a

6

Definition (continued)
For regular expressionsr1

andr2

L r1  r2  L r1   L r2 
L r1 r2  L r1  L r2 
L r1 *  L r1   *
L  r1   L r1 
7

Example
Regular expression: a  b  a *

L  a  b  a * L  a  b   L a *
L a  b  L a *
 L a   L b    L a   *
  a   b    a  *
 a, b   , a, aa, aaa,...

 a, aa, aaa,..., b, ba, baa,...
8

Example
Regular expression

r  a  b  *  a  bb 

L r   a, bb, aa, abb, ba, bbb,...

9

Example
Regular expression

r  aa  *  bb  * b

2n 2m

L r  {a b

b : n, m 0}

10

Example
Regular expression

r (0  1) * 00 (0  1) *

L(r ) = { all strings containing substring 00

11

Example
Regular expression r

(1  01) * (0   )

L(r ) = { all strings without substring 00 }

12

Equivalent Regular Expressions
Definition:
Regular expressions r1

andr2

are equivalent ifL( r1 ) L( r2 )

13

Example

L

= { all strings without substring 00 }

r1 (1  01) * (0   ) r2 (1* 011*) * (0   )  1* (0   )
L(r1 ) L(r2 ) L

r1

and r2 are equivalent regular expressions
14

Regular Expressions and Regular Languages

15

Theorem
Languages
Generated by

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Regular Expression

    • 322 Words
    • 2 Pages

    Write a regular expression for binary strings with at least two 0s but not consecutive 0s. 1*01+01* Write a regular expression that matches all strings over the alphabet {a, b, c} that contain: Starts and ends with a a(a*b*c*)a /( a / a(a/b)*a) At most one a b*c*/b*c* a b*c* At least two a's b*c* a b*c* a b*c* An even number of a's (b*c* a b*c* a b*c*)+ Number of a's plus number of b's is even Write a regular expression to describe all dates of the form…

    • 322 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    CS 3133 Foundations of Computer Science C term 2014 Solutions of the Sample Problems for the Midterm Exam 1. Give a regular expression that represents the set of strings over Σ = {a, b} that contain the substring ab and the substring ba. Solution: a+ b+ a(a ∪ b)∗ ∪ b+ a+ b(a ∪ b)∗ (20 points) 2. Consider the following grammar G: S → SAB|λ A → aA|a B → bB|λ (a) Give a leftmost derivation of abbaab. (b) Build the derivation tree for the derivation in part (1). (c) What is L(G)? Solution:…

    • 367 Words
    • 5 Pages
    Satisfactory Essays
  • Powerful Essays

    REGULAR EXPRESSIONS AND IT’S APPLICATIONS REGULAR EXPRESSIONS A regular expression is a specific pattern that provides concise and flexible means to "match" (specify and recognize) strings of text, such as particular characters, words, or patterns of characters. Common abbreviations for "regular expression” include regex and regexp. It is a Compact mechanism for defining a language. OPERANDS OF REGULAR EXPRESSION The empty string ε Single characters of the underlying…

    • 1179 Words
    • 5 Pages
    Powerful Essays
  • Satisfactory Essays

    Implementations of: Finite automata Regular expression Pushdown automata Engineering applications of finite automata The study of automata has been acquiring increasing importance for engineers in many fields. For some time, the capabilities of these automata have been of the greatest interest to logicians and mathematicians. However, the expanding literature on the use of finite automata as probabilistic models demonstrates the growing…

    • 524 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    Expressions

    • 1265 Words
    • 6 Pages

    expressions The Expressions Company began in 1988 as The Expressions Card and Stationery Shop, offering greeting cards and other paper products exclusively distributed by Sterling Paper. Two decades later, The Expressions store has grown to over 40 branches nationwide and has expanded its merchandise to include complete lines of school and office supplies, gift and novelty items, computer supplies and reading materials, living up to its current positioning as "Your affordable school and office…

    • 1265 Words
    • 6 Pages
    Powerful Essays
  • Powerful Essays

    Regular Polygon

    • 9255 Words
    • 38 Pages

    References: Bibliography * Coxeter, H.S.M.; Regular Polytopes, (Methuen and Co., 1948). * Cromwell, P.; Polyhedra, CUP hbk (1997), pbk. (1999). * Grünbaum, B.; Are your polyhedra the same as my polyhedra? Discrete and comput. geom: the Goodman-Pollack festschrift, ed. Aronov et al. Springer (2003)…

    • 9255 Words
    • 38 Pages
    Powerful Essays
  • Good Essays

    regular TA

    • 772 Words
    • 4 Pages

    Qualifications summary Successful completion of the Regular and Territorial Army Late Entry Officers Commissioning Course has been accredited by CMI as follows: CMI Level 7 Certificate in Strategic Management and Leadership (QCF) CMI level 7 management and leadership qualifications are developed for senior managers responsible for translating organisational strategy into effective performance. Level 7 qualifications portray practical management and leadership skills and competencies that are…

    • 772 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Expression

    • 640 Words
    • 3 Pages

    Alan Holmes Jr. Ms. Maureen Cunningham ENG 090, 4501 26 January 2011 What is expression? When I sit back and actually think about all the things that people do to express their thoughts, feelings, and beliefs, it really amazes me at the things people will do. It all starts when you are a young kid and you just have to tell everyone how you feel or what you saw. When you are young you will say exactly what is on your mind even if it is not in the best interest of others. Even though it seems…

    • 640 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Regular Exercise

    • 251 Words
    • 2 Pages

    weights. Normally after breakfast or lunch they barely move their feet outside the doors. As a result, they are overweight and having trouble on their health. Regular Exercise is necessary for physical fitness; Helps your body keep the average weights. What does regular exercise has anything to do with good health? Because doing regular exercises are able to kill all the diseases. For example, overweight people are having trouble with heart disease, like heavy breathing and lose of self-esteem.…

    • 251 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    regular verbs

    • 281 Words
    • 2 Pages

    In the English language verbs have different forms or tenses. There is the present tense, the simple past tense and past participle, to name a few. Most regular verbs have the simple past and the past participle spelled like the present tense except the past tenses have a “d” or “ed” added to the regular form. However, with irregular verbs it’s a different story. What are irregular verbs? Irregular verbs are common verbs in the English language that do not follow the simple system of adding “d”…

    • 281 Words
    • 2 Pages
    Satisfactory Essays