Common Regular Expression 2
-
Upload
yhet-esperanza -
Category
Documents
-
view
235 -
download
0
Transcript of Common Regular Expression 2
-
8/19/2019 Common Regular Expression 2
1/26
Prepared by: Genevieve C. Oca
AUTOMATA
(Regular Expression
-
8/19/2019 Common Regular Expression 2
2/26
Co!!on
Opera"ors #orRegularOpera"ors
-
8/19/2019 Common Regular Expression 2
3/26
Basic operators
$% &' escape . Arbi"rarycarac"er
)* carac"er class+ Op"ional
carac"er,% - repea"ed
expression al"erna"ive
/ beginning o# line 0 end o# line
1 "railing con"ex" 23 repe"i"ions
-
8/19/2019 Common Regular Expression 2
4/26
Basic operators
$% &' escape . Arbi"rarycarac"er
)* carac"er class+ Op"ional
carac"er,% - repea"ed
expression al"erna"ive
/ beginning o# line 0 end o# line
1 "railing con"ex" 23 repe"i"ions
-
8/19/2019 Common Regular Expression 2
5/26
Converts operators to text.
Exa!ples:
$+ rule #or a 4ues"ion !ar5
$, rule #or an as"eris5
&,' sa!e as above
a$-$- sa!e as &a--'
\, “” escape
-
8/19/2019 Common Regular Expression 2
6/26
Basic operators
$% &' escape . Arbi"rarycarac"er
)* carac"er class+ Op"ional
carac"er,% - repea"ed
expression al"erna"ive
/ beginning o# line 0 end o# line
1 "railing con"ex" 23 repe"i"ions
-
8/19/2019 Common Regular Expression 2
7/26
Stands for any character.
Exa!ples:
. Tis 6ill accep" one carac"er.oca. Tis 6ill accep" one carac"er
#ollo6ed by oca and ano"er carac"er
again. Exa!ple: vocal% local% e"c.
. Arbitrary character
-
8/19/2019 Common Regular Expression 2
8/26
Basic operators
$% &' escape . Arbi"rarycarac"er
)* carac"er class+ Op"ional
carac"er,% - repea"ed
expression al"erna"ive
/ beginning o# line 0 end o# line
1 "railing con"ex" 23 repe"i"ions
-
8/19/2019 Common Regular Expression 2
9/26
A se" o# carac"ers "a" can !a"ca single inpu" carac"er.All opera"ors beco!e "ex" inside acarac"er class excep" "e#ollo6ing: 7 (das indica"es range / (care" indica"es co!ple!en" $ (bac5slas escapes 6i"incarac"er class
[ ] character class
-
8/19/2019 Common Regular Expression 2
10/26
-
8/19/2019 Common Regular Expression 2
11/26
Basic operators
$% &' escape . Arbi"rarycarac"er
)* carac"er class+ Op"ional
carac"er,% - repea"ed
expression al"erna"ive
/ beginning o# line 0 end o# line
1 "railing con"ex" 23 repe"i"ions
-
8/19/2019 Common Regular Expression 2
12/26
9ero or one occurrence o# "epreceding expression.
)7-*+ op"ional nega"ive or posi"ivesignColou+r can !a"c color or colour
? ptional character
-
8/19/2019 Common Regular Expression 2
13/26
Basic operators
$% &' escape . Arbi"rarycarac"er
)* carac"er class+ Op"ional
carac"er,% - repea"ed
expression al"erna"ive
/ beginning o# line 0 end o# line
1 "railing con"ex" 23 repe"i"ions
-
8/19/2019 Common Regular Expression 2
14/26
, : 8ero or !ore occurrences o#"e preceding expression.- : one or !ore occurrences o#"e preceding expression.
)a78A79=*)a78A797;=*,
7rule #or an iden"i>er)7-*+)7;*-
7rule #or a (signed in"eger
!, " repeated expression
-
8/19/2019 Common Regular Expression 2
15/26
Basic operators
$% &' escape . Arbi"rarycarac"er
)* carac"er class+ Op"ional
carac"er,% - repea"ed
expression al"erna"ive
/ beginning o# line 0 end o# line
1 "railing con"ex" 23 repe"i"ions
-
8/19/2019 Common Regular Expression 2
16/26
Any o# "e al"erna"ive expressions6ill be recogni8ed.
Exa!ple:?@BDF; a digi"% "e
ard 6ayocacu!eo6 can !a"c oca orcu or !eo6
# altrnative
-
8/19/2019 Common Regular Expression 2
17/26
Basic operators
$% &' escape . Arbi"rarycarac"er
)* carac"er class+ Op"ional
carac"er,% - repea"ed
expression al"erna"ive
/ beginning o# line 0 end o# line
1 "railing con"ex" 23 repe"i"ions
-
8/19/2019 Common Regular Expression 2
18/26
Te expression #ollo6ing "isopera"or 6ill only be !a"ced i##ound a#"er a ne6line carac"eror a" "e beginning o# "e inpu"s"rea!.
Exa!ple:/(abcd ab or cd 6ill berecogni8ed only i# a#"er $n
$ be%innin% of line
-
8/19/2019 Common Regular Expression 2
19/26
Basic operators
$% &' escape . Arbi"rarycarac"er
)* carac"er class+ Op"ional
carac"er,% - repea"ed
expression al"erna"ive
/ beginning o# line 0 end o# line
1 "railing con"ex" 23 repe"i"ions
-
8/19/2019 Common Regular Expression 2
20/26
-
8/19/2019 Common Regular Expression 2
21/26
Basic operators
$% &' escape . Arbi"rarycarac"er
)* carac"er class+ Op"ional
carac"er,% - repea"ed
expression al"erna"ive
/ beginning o# line 0 end o# line
1 "railing con"ex" 23 repe"i"ions
-
8/19/2019 Common Regular Expression 2
22/26
Te #or!a" is: Expr?1Expr@. Tis!eans "a" Expr1 6ill berecogni8ed only i# #ound be#oreExpr2. Expr2 6ill no" beconsu!ed.
' trailin% context
-
8/19/2019 Common Regular Expression 2
23/26
Basic operators
$% &' escape . Arbi"rarycarac"er
)* carac"er class+ Op"ional
carac"er,% - repea"ed
expression al"erna"ive
/ beginning o# line 0 end o# line
1 "railing con"ex" 23 repe"i"ions
-
8/19/2019 Common Regular Expression 2
24/26
Allo6s dieren" 5inds o# repe"i"ion.Exa!ple:a2?%3 "e sa!e as (a|aa|aaa|aaaa|
aaaa)a2?%3 "e sa!e as a+% one or !orerepe"i"ions o# a
a2@%3 "6o (@ or !ore repe"i"ions o# aa23 exac"ly >ve ( repe"i"ions o# a
()
-
8/19/2019 Common Regular Expression 2
25/26
Basic operators
$% &' escape . Arbi"rarycarac"er
)* carac"er class+ Op"ional
carac"er,% - repea"ed
expression al"erna"ive
/ beginning o# line 0 end o# line
1 "railing con"ex" 23 repe"i"ions
-
8/19/2019 Common Regular Expression 2
26/26
$$,“* can do all thin%s thro+%h
Christho stren%thens -e”
/hilippians 0123