Results 1 to 5 of 5
  1. #1
    MiddleBlocker is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default String split help

    Hi Everyone,

    I am trying to parse a HTML table down to the contents I want.

    i.e. <td> 1 </td> and trying to get the 1 out.


    Given where the String scraw

    <td>1</td><td><a href="/site/1209">DOE/SC/LBNL/NERSC</a><br/>United States</td><td><a href="/system/10612">Hopper - Cray XE6 12-core 2.1 GHz</a> / 2010<br/>Cray Inc.</td><td>153408</td><td>1054.00</td><td>1288.63</td><td>2910.00</td></tr><tr class="odd">


    I have code:

    int f = 1;int g=2;


    for(int i = 0 ; i<5; i++)
    {
    int indexFirstComputer = stuff2.indexOf("<td>" + f + "</td>");
    int indexNextComputer = stuff2.indexOf("<td>" + g + "</td>");

    String[] Computers = new String[a];
    String info = stuff2.substring(indexFirstComputer,indexNextCompu ter);

    airports[i] = info;

    String scraw = airports[i];

    String[] SComputer;

    String delimitter = "\\>";

    System.out.println(scraw);

    SComputer = scraw.split(delimitter);

    for(int w=0; w<SComputer.length;w++)
    {
    System.out.println("Array: " + w + " " + SComputer[0]);
    }
    f++; g++;


    with output

    Array: 0 <td
    Array: 1 <td
    Array: 2 <td
    Array: 3 <td
    Array: 4 <td
    Array: 5 <td
    Array: 6 <td
    Array: 7 <td
    Array: 8 <td
    Array: 9 <td
    Array: 10 <td
    Array: 11 <td
    Array: 12 <td
    Array: 13 <td
    Array: 14 <td
    Array: 15 <td
    Array: 16 <td
    Array: 17 <td
    Array: 18 <td
    Array: 19 <td
    Array: 20 <td
    Array: 21 <td


    Help is much appreciated thank you!
    Last edited by MiddleBlocker; 03-11-2011 at 01:39 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    MiddleBlocker is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default

    too easy :P

  4. #4
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    354
    Rep Power
    5

    Default

    Pattern matcher may help ?

  5. #5
    MiddleBlocker is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default

    Ehhhhhhhhhhhhhh... Figured it out.

    Bonus brownie points to whoever see my n00bness.

    Thanks for the suggestions though! Tried them out and learned other stuff.

Similar Threads

  1. String split help
    By YoungJavaBoy in forum New To Java
    Replies: 7
    Last Post: 01-19-2011, 01:39 AM
  2. Split a String with split()--Help
    By danilson in forum New To Java
    Replies: 7
    Last Post: 11-19-2010, 04:08 PM
  3. String split
    By soccer_kid_6 in forum New To Java
    Replies: 3
    Last Post: 10-29-2010, 07:51 PM
  4. How to split a String using split function
    By Java Tip in forum java.lang
    Replies: 4
    Last Post: 04-17-2009, 08:27 PM
  5. How to split a String using split function
    By JavaBean in forum Java Tip
    Replies: 0
    Last Post: 10-04-2007, 09:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •