How to separate specific elements in string java

前端 未结 3 2067
面向向阳花
面向向阳花 2021-01-27 18:25

Example of what I want to do:
If you pass in \"abc|xyz\" as the first argument and \"|\" as the second argument the method returns List(\"abc

3条回答
  •  半阙折子戏
    2021-01-27 18:59

    Is it what you are looking for ??There is a predefined function in String class.Make use of it

     String original ="abc|xyz";
     String[] resulted =original.split("\\|");//returns a String array
    

    Play with the resulted array here.

    Good luck.

提交回复
热议问题