Creaticalmind

07 square brackets "[]" 본문

Regular expressions

07 square brackets "[]"

TigerBJ 2018. 4. 12. 15:45

Page 7

Inside square brackets "[]" a list of characters can be provided. The expression matches if any of these characters is found. The order of characters is insignificant.(Case 3)

Source

How do you do?

Case 1

Regular Expression:[oyu]
First match:How do you do?
All matches:How do you do?

Case 2

Regular Expression:[dH].
First match:How do you do?
All matches:Hodo you do?

Case 3

Regular Expression:[owy][yow]
First match:How do you do?
All matches:How do you do?


Case 1 [oyu]가 나타내는 것은 'o' or 'y' or 'u' 의 의미 이다. 그래서 3가지 중 하나의 문자에 대한 검색을 한다. 문자는 3개가 있지만, 하나의 문자를 검색하는 의미이다. All matches에서 you 를 보면,[y][o][u]를 하나씩 검색을 하는 것이다.


Case 2 [dH].는 [d or H][.] 을 나타내는 것이다. d나 H 그리고 문자 와일드카드 ' . '를 나타내는 것이다.


Case 3 [owy][yow]는 ['o' or 'w' or 'y']['y' or 'o' or 'w']를 나타내는 것이다. 


oy oo ow wy wo ww yy yo yw


http://zvon.org/comp/r/tut-Regexp.html#Pages~Page_7

Comments