title: How to split string from String array [] by strings (word by by word instead of characters) with delimitter?
body: <pre><code>void displayResult() {
      String str = "tamilnadu||chennai-karanataka||bengaluru";
      String[] res = str.split("\\-");
      System.out.println(res.length);//res length is 2 
  
      //res contains two strings splited by -
      String[] result = res.toString().split("\\||");
      //again splitting by || but getting as characters, i need to get word by      word
      // how to achieve this
      System.out.println(result.length);//result length is 28
  }
  // i was supposed to get tamilnadu and chennai from first string[] res
  </code></pre>
  
  <p>String[] res holds two strings split by - i am trying to split res in the same way to get strings split by || pipe symbol but i am getting as characters 
  how to get as like before</p>