Contents    Page-10    Prev    Next    Page+10    Index   

Regular Expressions

Regular expressions are a more convenient way (than a regular grammar) to specify a regular language. We will use lex conventions for specifying regular expressions. An expression is specified in left-to-right order.

Expression: Meaning:
[ chars ] Any member of the set of characters
chars .
[ c1 - c2 ] Any character from c1 through c2 .
[^ chars ] Any character except chars .
( specs ) Used to group specifications specs .
{ category } An instance of a previously named
category .
" string " Exactly the specified string .
s1 | s2 s1 or s2
spec * Zero or more repetitions of spec .
spec + One or more repetitions of spec .
spec ? Optional spec .
spec { m,n} m through n repetitions of spec .