Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- history
- django
- Italy
- programming_book
- QT
- program
- hadoop
- MySQL
- management
- comic agile
- France
- essay
- web
- Malaysia
- agile
- Python
- hbase
- Software Engineering
- leadership
- Book
- Java
- Linux
- Spain
- Programming
- Book review
- ubuntu
- Kuala Lumpur
- RFID
- Artificial Intelligence
- erlang
Archives
- Today
- Total
python 한글 unicode/utf-8 pattern matching 본문
- 상황; 유니코드 한글만 pattern matching으로 찾고 싶은 경우
- unicode table; http://jrgraphix.net/r/Unicode/AC00-D7AF
- >>> print unichr(int('AC00', 16))
가
>>> print unichr(int('D7A3', 16))
힣
>>> korPattern = re.compile(u'[\uAC00-\uD7A3]+', re.U)
>>> t = u'[[프랑스]] [[파리 (프랑스)|파리]]'
>>> for m in re.finditer(korPattern, t): print m.group()
...
프랑스
파리
프랑스
파리 - utf-8
- >>> korPattern = re.compile('([\xE0-\xFF][\x80-\xFF][\x80-\xFF])+')
>>> t = '[[프랑스]] [[파리 (프랑스)|파리]]'
>>> for m in re.finditer(korPattern, t): print m.group()
...
프랑스
파리
프랑스
파리 - 참고
Comments