본문 바로가기

Software/Docs

Regular Expression





 ^ caret
^aaa
the first line or beginning of string
in the beginning of string, if there is "aaa" then true,otherwise false




$ dollar
aaa$
end of line or end of string
in the end of line, if the line end with "aaa", then true, otherwise false




 . period
^a.c
a..b$
exact one character
"abc","adc","aZc",.. are true, "aa" is false
end of string with these string,"aaab","abbb",azzb",..., then true




 [] bracket
[^xxxx]
[:string class:]
[:digit:]
[:alpha:]
[abc]
[Yy]
[A-Za-z0-9]
[-A-Z]
[^a-z]
[^0-9]
[[:digit:]]
 means reange or group, between two character use "-"
^ inside of [], means not
string class, alpha, blank,cntrl, digit,graph,lower,print,space,upper,xdigit
same with [0-9]
same with [A-Za-z]
same with [a-c]. so, "a","b","c" one of these are true
Y or y is true
all alphabet and numbers
with hyphen and all capital
except lowercase, all string
except number, all string
same with [0-9]




 {} brace
a{3}
a{3,}
a{3,5}
ab{2,3}
[0-9]{2}
doc[7-9]{2}
[^Zz]{5}
.{3,4}er
{} means range or repeat for right before the character
repeat 'a' only, so only "aaa" is true
'a' repeat more than three, so "aaa","aaaa","aaaaa",... are true
only "aaa","aaaa","aaaaa" are true
only "abb","abbb" are true
two digit number
"doc77","doc87","doc97" ...., are true
without Z and z, five character, "abcde", "ttttt"..., are true
before "er" needs three or four character, Peter,mother, but not brother




 * asterisk
ab*c
*
.*
ab*
a*
doc[7-9]*
[A-Z].*
like.*
means right before character does appear 0 or more, same as {0,}
"ac", "ackdddd", "abc", "abbc", "abbbbbbbc" , etc are true
there is no previous character, some characters or space are true
"." means one more character, so one more characters or space are not true
"b" can repeat 0 or mroe, so 'a', "accc", "abb", "abbbbbbb" are true
'a' repeat 0 or more, so k, kdd, sdfrrt, a, aaaa, abb, space, ...
doc7,doc777,doc778989,doc,... are true
the string are composed with only capital
previous character is 'a', so like, likely, liker, likelihood...are true




 plus
ab+c
ab+
like.+
[A-Z]+
 previous a character repeats one or more like {1,}
abc, abckdddd, abbc, abbbbbbbc ....are true, but not ac
repeat 'b' one or more, so " ab", "abccc", "abb", "abbbbbbb"...,
after "like" one character and one or more, "likely", liker, likelihood..., but not "like"
capital string




 ? question
ab?c
previous a character repeat 0 or one
only "abc", "abcd" are true




 () parenthesis it used for group in regular expression




 | bar
a|b|c
yes|Yes
korea|japan|chinese
means or
same as [a-c] means one of 'a','b','c'
same as [yY]es
one of "korea","japan","chinese"




 \ backslash
 use to display special character in the string




   




   




   










































from : http://ttongfly.net/zbxe/?document_srl=43635