Web Analytics Made Easy -
StatCounter Javascript Parser - CodingForum


No announcement yet.

Javascript Parser

  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript Parser

    I am looking for some assistance in writing a javascript parser for tab delimited line of text.

    Below is how the data is supplied to be via a blank HTML page:

    # Symbol|Name|Last|CuVol|Time
    RIN|Rinker Grp Ltd ADR|47.4800|10600|12:23:20

    I would like to extract each value as its own variable.

    Any assistance on some sample code would be appreciated.

  • #2
    Try the String.split function


    Store your value in a variable and split it, you'll get an array:

    var str = "a|b|c|d|e|F";
    var splitArray = str.split("|");
    alert(splitArray[0]); // a
    alert(splitArray[1]); // b


    • #3

      I would prefer to do that, but I am not sure how to take a plain text file and make the a|b|c|d a variable.


      • #4
        hmm, as far as I know java script is disabled by default to take any file at all from client machine, mybe M$ IE allows something like this, but I doubt.

        It is the security thing, you wouldnt like me with my java script to mess your file system, do you ? (-:

        so the only way is to read file from your server, send its contence as text to client and split it as mentioned before.
        Found a flower or bug and don't know what it is ?
        agrozoo.net galery
        if you don't spot search button at once, there is search form:
        agrozoo.net galery search