拆分字符串具有带正则表达式的符号(许多管道)(Split string has symbols(many pipes) with regex)
我有字符串word1|word2||||word3||word4| ,我试过line.split("\\|"); 但是这只会分割一个管道,可以处理我的情况的正则表达式是什么。
I have string word1|word2||||word3||word4| , i tried line.split("\\|"); but this will split just one pipe what's the regex that can handle my case.
最满意答案
您可以使用"\\|+"来匹配多个(1个或更多)管道。
line.split("\\|+");Ideone演示
You can use "\\|+" to match multiple (1 or more) pipes.
line.split("\\|+");Ideone Demo
更多推荐
发布评论