複数の区切り記号の文字列を分割します。
1877 ワード
原文のリンク:http://www.cnblogs.com/ray-mmss/p/10464590.html
map実現
RE.スプリット実現
転載先:https://www.cnblogs.com/ray-mmss/p/10464590.html
map実現
def mySplit(s, ds):
res = [s]
for d in ds:
t = []
list(map(lambda x: t.extend(x.split(d)), res))
res = t
return [x for x in res if x]
s = 'ab;cd|efg|hi,jkl|mn\topq;rst,uvw\txyz'
ds = ';,|\t'
print(mySplit(s, ds))
RE.スプリット実現
import re
s = 'ab;cd|efg|hi,jkl|mn\topq;rst,uvw\txyz'
ds = ';,|\t'
print(re.split(r'[,;\t|]+', s))
転載先:https://www.cnblogs.com/ray-mmss/p/10464590.html