Showing posts with label 正規表現. Show all posts
Showing posts with label 正規表現. Show all posts

Sunday, September 11, 2016

sed: Regular Expression Character Classes Behavior: Examples

Command:

$ echo {0..1}{e..h}{E..H}


Result:

0eE 0eF 0eG 0eH 0fE 0fF 0fG 0fH 0gE 0gF 0gG 0gH 0hE 0hF 0hG 0hH 1eE 1eF 1eG 1eH 1fE 1fF 1fG 1fH 1gE 1gF 1gG 1gH 1hE 1hF 1hG 1hH


Command:

$ echo {0..1}{e..h}{E..H} | sed 's/[[:alnum:]]/*/g'



Result:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***


Command:

$ echo {0..1}{e..h}{E..H} | sed 's/[[:alpha:]]/*/g'


Result:

0** 0** 0** 0** 0** 0** 0** 0** 0** 0** 0** 0** 0** 0** 0** 0** 1** 1** 1** 1** 1** 1** 1** 1** 1** 1** 1** 1** 1** 1** 1** 1**


Command:

$ echo {0..1}{e..h}{E..H} | sed 's/[[:blank:]]/*/g'


Result:

0eE*0eF*0eG*0eH*0fE*0fF*0fG*0fH*0gE*0gF*0gG*0gH*0hE*0hF*0hG*0hH*1eE*1eF*1eG*1eH*1fE*1fF*1fG*1fH*1gE*1gF*1gG*1gH*1hE*1hF*1hG*1hH


Command:

$ echo {0..1}{e..h}{E..H} | sed 's/[[:cntrl:]]/*/g'


Result:

0eE 0eF 0eG 0eH 0fE 0fF 0fG 0fH 0gE 0gF 0gG 0gH 0hE 0hF 0hG 0hH 1eE 1eF 1eG 1eH 1fE 1fF 1fG 1fH 1gE 1gF 1gG 1gH 1hE 1hF 1hG 1hH


Command:

$ echo {0..1}{e..h}{E..H} | sed 's/[[:digit:]]/*/g'


Result:

*eE *eF *eG *eH *fE *fF *fG *fH *gE *gF *gG *gH *hE *hF *hG *hH *eE *eF *eG *eH *fE *fF *fG *fH *gE *gF *gG *gH *hE *hF *hG *hH


Command:

$ echo {0..1}{e..h}{E..H} | sed 's/[[:graph:]]/*/g'


Result:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***


Command:

$ echo {0..1}{e..h}{E..H} | sed 's/[[:lower:]]/*/g'


Result:

0*E 0*F 0*G 0*H 0*E 0*F 0*G 0*H 0*E 0*F 0*G 0*H 0*E 0*F 0*G 0*H 1*E 1*F 1*G 1*H 1*E 1*F 1*G 1*H 1*E 1*F 1*G 1*H 1*E 1*F 1*G 1*H


Command:

$ echo {0..1}{e..h}{E..H} | sed 's/[[:print:]]/*/g'


Result:

*******************************************************************************************************************************


Command:

$ echo {0..1}{e..h}{E..H} | sed 's/[[:punct:]]/*/g'


Result:

0eE 0eF 0eG 0eH 0fE 0fF 0fG 0fH 0gE 0gF 0gG 0gH 0hE 0hF 0hG 0hH 1eE 1eF 1eG 1eH 1fE 1fF 1fG 1fH 1gE 1gF 1gG 1gH 1hE 1hF 1hG 1hH


Command:

$ echo {0..1}{e..h}{E..H} | sed 's/[[:space:]]/*/g'


Result:

0eE*0eF*0eG*0eH*0fE*0fF*0fG*0fH*0gE*0gF*0gG*0gH*0hE*0hF*0hG*0hH*1eE*1eF*1eG*1eH*1fE*1fF*1fG*1fH*1gE*1gF*1gG*1gH*1hE*1hF*1hG*1hH


Command:

$ echo {0..1}{e..h}{E..H} | sed 's/[[:upper:]]/*/g'


Result:

0e* 0e* 0e* 0e* 0f* 0f* 0f* 0f* 0g* 0g* 0g* 0g* 0h* 0h* 0h* 0h* 1e* 1e* 1e* 1e* 1f* 1f* 1f* 1f* 1g* 1g* 1g* 1g* 1h* 1h* 1h* 1h*


Command:

$ echo {0..1}{e..h}{E..H} | sed 's/[[:xdigit:]]/*/g'


Result:

*** *** **G **H *** *** **G **H *g* *g* *gG *gH *h* *h* *hG *hH *** *** **G **H *** *** **G **H *g* *g* *gG *gH *h* *h* *hG *hH