顯示具有 字串切割(string split) 標籤的文章。 顯示所有文章
顯示具有 字串切割(string split) 標籤的文章。 顯示所有文章

2013年12月25日 星期三

多重分隔號字串切割之方法暨效能比較 ( Compare performance of string splitting with multiple delimiters )

在Python中,str內建split()函式(method)做字串分割用
strT = "a1,a2,a3"
strT.split(',')

#output => ['a1', 'a2', 'a3']
單個分隔符號可以使用split()
本文探討多個分隔符號(例如:"a1,a2;a3-a4#a5")情況下的字串分割方法並比較其效能:
目標:
input: "a1,a2;a3-a4#a5"
output: ["a1", "a2", "a3", "a4", "a5"]