re:split/3
用正则表达式去截取数据
用法:
split(Subject,RE,Options) -> SplitList
通过正则表达式(RE)来找到截取标记,然后把数据(Subject)截取分开。同时,这是一个全局匹配截取,只要出现截取标记的地方都会被截取分开。返回的截取列表(SplitList)里只返回被截取分开的数据,截取标记不会返回。
参数 Options 提供一些截取匹配选项,例如要求返回的数据是字符串形式:
re:split("red - green - blue", "-", [{return, list}]).
Str = "The text matching the subexpression (marked by the parentheses in the regexp) is inserted in the result list where it was found.", re:split(Str, "[|,|\\.|;|:|\\t|\\n|\\(|\\)|\\s|]+", [{return, list}]).