Возможно, мы сможем зафиксировать желаемый результат с помощью простого выражения с левой границей только '
, а затем собрать буквы, как:
'([\p{L}]+)
Тест
# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"'([\p{L}]+)"
test_str = ("'가락시장(340)',\n"
" '가락시장(8)',\n"
" '가산디지털단지(7)',\n"
" '강남(222)',\n"
" '강남구청',\n"
" '강동',\n"
" '강동구청',\n"
" '강변(214)',\n"
" '개롱',\n"
" '개화산',\n"
" '거여',\n"
" '건대입구(212)',\n"
" '건대입구(7)',\n"
" '경복궁(317)',\n"
" '경찰병원(341)',\n"
" '고덕',\n"
" '고려대',\n"
" '고속터미널(329)',\n"
" '고속터미널(7)',\n"
" '공덕(5)',\n"
" '공덕(6)',\n"
" '공릉',\n"
" '광나루',")
matches = re.finditer(regex, test_str, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
![enter image description here](https://i.stack.imgur.com/PX5Tu.png)
RegEx
Если это выражение нежелательно, его можно изменить или изменить в regex101.com .
RegEx Circuit
jex.im визуализирует регулярные выражения:
Ссылка
Как реализовать \ p {L} в регулярных выражениях Python