homework regexref
TRANSCRIPT
8/19/2019 Homework RegexRef
http://slidepdf.com/reader/full/homework-regexref 1/4
Copyright © 2010-2014 Cloudera, Inc. All rights reserved.
Not to be reproduced without prior written consent.
1
Apache Hadoop –
A course for undergraduates
Regular Expression Reference
for Labs
8/19/2019 Homework RegexRef
http://slidepdf.com/reader/full/homework-regexref 2/4
Copyright © 2010-2014 Cloudera, Inc. All rights reserved.
Not to be reproduced without prior written consent.
2
Regular Expression Reference
!"# %&''&()*+ ), - ./)#% 010&/)-' )*0#*2#2 %&/ 0"# 3&*4#*)#*3# &% ,012#*0, ("& 2&*50
"-4# #67#/)#*3# 1,)*+ /#+1'-/ #67/#,,)&*, &/ 8-9 *##2 - /#%/#,"#/: ; 8&/#
3&87'#0# /#%#/#*3# 3-* .# %&1*2 )* 0"# 2&318#*0-0)&* %&/ <-4-5, =-00#/* 3'-,,>
http://tiny.cloudera.com/dae9a
Introduction to Regular Expressions
?#+1'-/ #67/#,,)&*, -/# 1,#2 %&/ 7-00#/* 8-03")*+: !"#/# -/# 0(& @)*2, &% 7-00#/*,
)* /#+1'-/ #67/#,,)&*,> ')0#/-', -*2 8#0-3"-/-30#/,: A)0#/-' 4-'1#, -/# 1,#2 0& 8-03"
7/#3),# 7-00#/*, (")'# 8#0-3"-/-30#/, "-4# ,7#3)-' 8#-*)*+B %&/ #6-87'#C - 2&0 ()''
8-03" -*9 ,)*+'# 3"-/-30#/: D#/#E, 0"# 3&87'#0# '),0 &% 8#0-3"-/-30#/,C %&''&(#2 .9#67'-*-0)&*, &% 0"&,# 0"-0 -/# 3&88&*'9 1,#2>
< ( [ { \ ^ - = $ ! | ] } ) ? * + . >
A)0#/-' 3"-/-30#/, -/# -*9 3"-/-30#/, *&0 '),0#2 -, - 8#0-3"-/-30#/: !"#9E/# 8-03"#2
#6-30'9C .10 )% 9&1 (-*0 0& 8-03" - 8#0-3"-/-30#/C 9&1 81,0 #,3-7# )0 ()0" -
.-3@,'-,": F)*3# - .-3@,'-," ), )0,#'% - 8#0-3"-/-30#/C )0 81,0 -',& .# #,3-7#2 ()0" -
.-3@,'-,": G&/ #6-87'#C 9&1 (&1'2 1,# 0"# 7-00#/* \\. 0& 8-03" - ')0#/-' 2&0:
?#+1'-/ #67/#,,)&*, ,177&/0 7-00#/*, 813" 8&/# %'#6).'# 0"-* ,)87'9 1,)*+ - 2&0 0&
8-03" -*9 3"-/-30#/: !"# %&''&()*+ #67'-)*, "&( 0& 1,# !"#$#!%&$ !(#))&) 0& /#,0/)30
(")3" 3"-/-30#/, -/# 8-03"#2:
Character Classes
[057] H-03"#, -*9 ,)*+'# 2)+)0 0"-0 ), #)0"#/ IC JC &/ K
[0-9] H-03"#, -*9 ,)*+'# 2)+)0 .#0(##* I -*2 L
[3-6] H-03"#, -*9 ,)*+'# 2)+)0 .#0(##* M -*2 N
[a-z] H-03"#, -*9 ,)*+'# '&(#/3-,# '#00#/
[C-F] H-03"#, -*9 ,)*+'# 177#/3-,# '#00#/ .#0(##* O -*2 G
G&/ #6-87'#C 0"# 7-00#/* [C-F][3-6] (&1'2 8-03" 0"# ,0/)*+ D3 &/ F5 .10 (&1'2
%-)' 0& 8-03" G3 &/ C7:
!"#/# -/# -',& ,&8# .1)'0P)* 3"-/-30#/ 3'-,,#, 0"-0 -/# ,"&/0310, %&/ 3&88&* ,#0, &%
3"-/-30#/,:
8/19/2019 Homework RegexRef
http://slidepdf.com/reader/full/homework-regexref 3/4
Copyright © 2010-2014 Cloudera, Inc. All rights reserved.
Not to be reproduced without prior written consent.
3
Predefined Character Classes
\\d H-03"#, -*9 ,)*+'# 2)+)0
\\w H-03"#, -*9 (&/2 3"-/-30#/ Q'#00#/, &% -*9 3-,#C 7'1, 2)+)0, &/
1*2#/,3&/#R
\\s H-03"#, -*9 (")0#,7-3# 3"-/-30#/ Q,7-3#C 0-.C *#(')*#C #03:R
G&/ #6-87'#C 0"# 7-00#/* \\d\\d\\d\\w (&1'2 8-03" 0"# ,0/)*+ 314d &/ 934X
.10 (&1'2 %-)' 0& 8-03" 93X &/ Z871:
F&8#0)8#, )0E, #-,)#/ 0& 3"&&,# ("-0 9&1 2&*E0 (-*0 0& 8-03" )*,0#-2 &% ("-0 9&1
2& (-*0 0& 8-03": !"#,# 0"/## 3-* .# *#+-0#2 .9 1,)*+ -* 177#/3-,# '#00#/ )*,0#-2:
Negated Predefined Character Classes
\\D H-03"#, -*9 ,)*+'# *&*P2)+)0 3"-/-30#/
\\W H-03"#, -*9 *&*P(&/2 3"-/-30#/\\S H-03"#, -*9 *&*P(")0#,7-3# 3"-/-30#/
G&/ #6-87'#C 0"# 7-00#/* \\D\\D\\W (&1'2 8-03" 0"# ,0/)*+ ZX# &/ @ P .10
(&1'2 %-)' 0& 8-03" 93X &/ 36_:
!"# 8#0-3"-/-30#/, ,"&(* -.&4# 8-03" #-3" #6-30'9 &*# 3"-/-30#/: S&1 3-* ,7#3)%9
0"#8 81'0)7'# 0)8#, 0& 8-03" 8&/# 0"-* &*# 3"-/-30#/C .10 /#+1'-/ #67/#,,)&*,
,177&/0 0"# 1,# &% T1-*0)%)#/, 0& #')8)*-0# 0"), /#7#0)0)&*:
Matching Quantifiers{5} =/#3#2)*+ 3"-/-30#/ 8-9 &331/ #6-30'9 %)4# 0)8#,
{0,6} =/#3#2)*+ 3"-/-30#/ 8-9 &331/ .#0(##* U#/& -*2 ,)6 0)8#,
? =/#3#2)*+ 3"-/-30#/ ), &70)&*-' Q8-9 &331/ U#/& &/ &*# 0)8#,R
+ =/#3#2)*+ 3"-/-30#/ 8-9 &331/ &*# &/ 8&/# 0)8#,
* =/#3#2)*+ 3"-/-30#/ 8-9 &331/ U#/& &/ 8&/# 0)8#,
V9 2#%-1'0C T1-*0)%)#/, 0/9 0& 8-03" -, 8-*9 3"-/-30#/, -, 7&,,).'#: W% 9&1 1,#2 0"#
7-00#/* ore.+a &* 0"# ,0/)*+ Dualcore has a store in FloridaC 9&1
8)+"0 .# ,1/7/),#2 0& '#-/* 0"-0 )0 8-03"#, ore has a store in Florida
/-0"#/ 0"-* ore ha &/ ore in Florida -, 9&1 8)+"0 "-4# #67#30#2: !"), ),
.#3-1,# 8-03"#, - X+/##29X .9 2#%-1'0: ;22)*+ - T1#,0)&* 8-/@ 8-@#, 0"#
T1-*0)%)#/ 8-03" -, %#( 3"-/-30#/, -, 7&,,).'# )*,0#-2C ,& 0"# 7-00#/* ore.+?a &*
0"), ,0/)*+ (&1'2 8-03" ore ha:
8/19/2019 Homework RegexRef
http://slidepdf.com/reader/full/homework-regexref 4/4
Copyright © 2010-2014 Cloudera, Inc. All rights reserved.
Not to be reproduced without prior written consent.
4
G)*-''9C 0"#/# -/# 0(& ,7#3)-' 8#0-3"-/-30#/, 0"-0 8-03" U#/& 3"-/-30#/,: !"#9 -/#
1,#2 0& #*,1/# 0"-0 - ,0/)*+ 8-03"#, - 7-00#/* &*'9 ("#* )0 &331/, -0 0"# .#+)**)*+
&/ #*2 &% - ,0/)*+:
Boundary Matching Metacharacters^ H-03"#, &*'9 -0 0"# .#+)**)*+ &% - ,0/)*+
$ H-03"#, &*'9 -0 0"# #*2)*+ &% - ,0/)*+
YZ![> \"#* 1,#2 )*,)2# ,T1-/# ./-3@#0, Q(")3" 2#*&0# - 3"-/-30#/ 3'-,,RC 0"# ^
3"-/-30#/ ), )*0#/#7/#0#2 2)%%#/#*0'9: W* 0"-0 3&*0#60C )0 *#+-0#, 0"# 8-03": !"#/#%&/#C
,7#3)%9)*+ 0"# 7-00#/* [^0-9] ), #T1)4-'#*0 0& 1,)*+ 0"# 7/#2#%)*#2 3"-/-30#/ 3'-,,
\\d 2#,3/).#2 #-/')#/: