Regular Expressions
Language
Human using complex systems of language Examples :
capacity for acquiring and communication , and a
is
any specific example of such a system
.
Gab ,
aa , ba , bby
In mathematics , computer science and linguistics a Eb aa aba, cbc, abobal
, formal language consists of words whose letters ,
, ,
taken from an alphabet and are well-formed according to a specific set of rules.
are
Sa ,
ab , abb , abbb, ...
3
Formal Language
Symbols Alphabet Word (or strings
concatenation with
· a
,
b, c, 0 ,
1 [a
·
,
b,
ch ·
abc , ana bbbbbca , a,
·
abc .
e = abc
, empty word
· r , 9, ·
40 , 13 · abc . bc =
abobes concatenation
·
(a) = aa
11 Caba)
· = abaaba aba
·
,
·
E < empty word
⑧
11 (
· red , green ,
blue
Now languages from old (set theory ( Kloone Star
Sab babuda, , by =
Sa ,
b , ab , bay L . La = (s t . s th , t t(z] ↳* =
(5 32
, ...
Sn nEIN
,
Sitt for all 0 bi
In]
2
lab , bay e gab by ,
=
(ab] ↳ =
L L .
** =
(2) =
10
3
Cab bas sab by =
[ba) ↳ = W L L .
.
, ,
L =
u(E) L Lu = L d h . .
... L
-
n times
Examples
[ = (a b, c) alphabet For given alphabet [we define language L( *)
,
a can a
such that
Lo =
(a , b)
Li =
Laa ,
ab
,
ac
,
ba bb , be ca ob
, , , , ] L( E) =
[7 ,
X2 ... In nEIN , Vie for all 0<i < n]
ha = Lo Lo . =
Gaa ,
ab , ba , bby
Le =
[V x ,
...
En neI
,
ne3
,
i ] all the words that are a
sequence on n characters such that
u is natural number and less than equal to
Sa is
a n or 3 and
=
,
bab , a
,
b
, c, a ,
...
] &i is in the alphabet I .
↳ G =
my ↳ Gha
ha = Cave ...
In NEI
,
Vie I ] < all the words that are a
sequence on n characters and
· xplicitely start with an 'a' Such thata is a natural number and
= Sabc , ada
,
aba
, a
,
...
Y &i is in the alphabet I .
↳ nhn = Saa ,
ab , acs
↳ (n = (ba ,
bb
,
bc , ca
,
(b
, <)
Li =
Slab)"nEIN] all the words that are a sequence of 'ab' concatenated to itself
n times such that n is a natural number
.
=
[2 ,
ab
,
abab
,
ababab
, ....
Regular Expressions
Definition 1: Let I be an alphabet. A pattern or
regular expression over I is any word over
Examples
Joat = v (0 ,
3
,, *, ( , 13 Operators > [0 ,
2
,
X
, 1 ,
*
]
*
generated by the
following recursive definition .
· I =
(a by , (a(b)
Empty pattern : The character I is a pattern
·
I = (a , b, 2) ((alb) (c) or (a)(b(c)) or
Calblc)
Empty word : The character a is a pattern
Letters : Every letter from I is a pattern
Concatenation : if p , and pe are patterns then so is (pipe)
Alternative If :
p, and pe are patterns then so is (p /Pc)
,
if pattern then (p )
*
Kleene star : p is a so is