最近项目里出现了大量的scan方法。查看了下资料，明白了它的意思。 scan 是 将满足条件（如正则表达式过滤后）的字符串返回到数组， split 是将满足条件的内容为分割点，将分割点左右两边的字符串返回到数组中。不知道这样理解是否有偏差 The output of String#split doesn't include the delimiter. Rather, everything except the delimiter would be returned in the output array, while the output of String#scan would only include what is matched by the delimiter.
A delimited string split on | returns everything surrounding the | delimiters
Prints: ["a", "delimited", "string"]
The same string scanninng for | only returns the matched |
Prints: ["|", "|"]
Both of the above would also accept a regular expression in place of the simple string "|".
Split on everything between and including two t's
Prints: ["a|delimi", "ring"]
Search for everything between and including two t's