pipe simple split in java

前端 未结 1 862
半阙折子戏
半阙折子戏 2021-01-21 21:27

am getting problem while using split with pipeline.but with other characters it works well.What am doing wrong please help me.

String s =\"H|PONumber1|1|1\";
Str         


        
相关标签:
1条回答
  • 2021-01-21 22:03

    The pipe is being treated as a regex special character. Just escape it via \\| and you'll be good. From the javadoc on String.split...

    Splits this string around matches of the given regular expression.

    If you want to be safe, always pass your text to Pattern.quote(stringToSplitOn);

    0 讨论(0)
提交回复
热议问题