1. 程式人生 > >拆分多種分隔符的字符串

拆分多種分隔符的字符串

spl bsp int ret tsd print res return end

1.

def MySplit(x,ds):

  res = [x]

  for d in ds:

    t = []

    map(lambda x: t.extend(x.split(d)),res)

    res = t

  return (x for x in res if x)

x = "ads,ds;sd?dsds\tsd|e"

print (res)

2.

import re

re.split(‘[,;\t?|]+‘,x)

拆分多種分隔符的字符串