Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>1st Way:</h2> <ul> <li>You can first split your string on the basis of <code>:::</code>. This will give you an array of length 3. You would be interested in the <code>2nd</code> and the <code>3rd</code> element of your array.</li> <li>Then split the <code>2nd element</code> of your array on <code>::</code>. This will give you an array containing <code>each name</code>.</li> <li><p>Iterate over the <code>2nd array</code> and print each name with the <code>3rd element</code> of your first array.</p> <pre><code>String str = "books/eh/grayL88/WilliamsMC88:::M. Howard Williams::" + "P. A. Massey::Jim A. Crammond:::Benchmarking Prolog for " + "Database Applications."; String[] arr = str.split(":::"); String[] innerArr = arr[1].split("::"); for (String name: innerArr) { System.out.println(name + " -- " + arr[2]); } </code></pre></li> </ul> <p><strong>OUTPUT</strong>: -</p> <blockquote> <p>M. Howard Williams -- Benchmarking Prolog for Database Applications.<br/> P. A. Massey -- Benchmarking Prolog for Database Applications. <br /> Jim A.Crammond -- Benchmarking Prolog for Database Applications.</p> </blockquote> <hr> <h2>2nd Way:</h2> <p>Or, you can split on <code>:::?</code>. This will split on <code>::</code> or <code>:::</code>, that will get each individual elements in your first array only (Will work only for <code>3</code> names. For more, you should better use the first one)</p> <pre><code> String[] arr = str.split(":::?"); System.out.println(arr[1] + " - " + arr[4]); System.out.println(arr[2] + " - " + arr[4]); System.out.println(arr[3] + " - " + arr[4]); </code></pre> <p><strong>OUTPUT</strong>: -</p> <blockquote> <p>M. Howard Williams - Benchmarking Prolog for Database Applications.<br />P. A. Massey - Benchmarking Prolog for Database Applications. <br />Jim A. Crammond - Benchmarking Prolog for Database Applications.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload