python 3正規表現
2716 ワード
ネット上でいくつかの例を探して改善した.
# -*- coding: UTF-8 -*-
import re
#
test = u'hello , world '
#
chinese_pattern = u'[\u4e00-\u9fa5]+'
says = re.findall(chinese_pattern, test)
#
hi = ''
for say in says:
print(say)
hi += say + ','
hi = hi.strip(',')
# : ,
print(hi)
def Find(string):
# findall()
url = re.findall('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', string)
return url
string = 'Runoob :https://www.runoob.com,Google :https://www.google.com'
print("Urls: ", Find(string))