Extract words from JSP into text file


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Extract words from JSP into text file

  1. #1
    Michelle Guest

    Extract words from JSP into text file


    Hi,

    I have a big problem:

    I want to extract selected words from a jsp file.
    Following are found in one of my jsp file:

    E.g.
    1) <td width="217"><font face="verdana,arial" size=2>ORGANISATION UNIT NAME<font
    color="#FF0000"> <font
    id="fontMandatory">*</font></font>

    I want to retrieve "ORGANISATION UNIT NAME"

    2)errPrompt(frm.txtDesc, "Maximum length is just 100 character only");

    I want to retrieve "Maximum length is just 100 character only"

    I try String tokenising, then check that is the token ends with ">", then
    the next token is the one
    I want, then loop until "<" is found. BUT this would not work as there is
    no spacing between some of
    the tags and the words.(e.g. <p>abc)--> This cauese the whole token to be
    <p>abc, so the "abc" will
    not be extracted as it does not have a "ends with >" in front of it.
    Even with using ">" as a checking does not work for pop up messages, as it
    does not have tags(refer
    to e.g 2).

    Please reply a.s.a.p...
    Really urgent!!
    Thank You

    Michelle

  2. #2
    Paul Clapham Guest

    Re: Extract words from JSP into text file

    If you set up your StringTokenizer correctly, you should be using "<>" for
    your delimiters. You should also be using the constructor that allows you
    to get the delimiters back as tokens. Then, when you get ">" as a token,
    you know the next token is one of the things you want.

    PC2

    "Michelle" <michellelimmx@hotmail.com> wrote in message
    news:3c746530$1@10.1.10.29...
    >
    > Hi,
    >
    > I have a big problem:
    >
    > I want to extract selected words from a jsp file.
    > Following are found in one of my jsp file:
    >
    > E.g.
    > 1) <td width="217"><font face="verdana,arial" size=2>ORGANISATION UNIT

    NAME<font
    > color="#FF0000"> <font
    > id="fontMandatory">*</font></font>
    >
    > I want to retrieve "ORGANISATION UNIT NAME"
    >
    > 2)errPrompt(frm.txtDesc, "Maximum length is just 100 character only");
    >
    > I want to retrieve "Maximum length is just 100 character only"
    >
    > I try String tokenising, then check that is the token ends with ">", then
    > the next token is the one
    > I want, then loop until "<" is found. BUT this would not work as there is
    > no spacing between some of
    > the tags and the words.(e.g. <p>abc)--> This cauese the whole token to be
    > <p>abc, so the "abc" will
    > not be extracted as it does not have a "ends with >" in front of it.
    > Even with using ">" as a checking does not work for pop up messages, as it
    > does not have tags(refer
    > to e.g 2).
    >
    > Please reply a.s.a.p...
    > Really urgent!!
    > Thank You
    >
    > Michelle




  3. #3
    foo Guest

    Re: Extract words from JSP into text file


    Michelle,

    If this is a 1-time thing (say, as an attempt at internationalization), you
    may be better off using Perl rather than Java as your extraction language.

    For example:

    while (<>) {
    @matches = />([^<]+)<)/g;
    }

    Will read in a passed-in file line by line and for each line return an array
    of >...< matches.

    IMO what you're going to come up against is that you'll be hard pressed to
    come up with parsing rules that are specific enough to cull out just the
    text you want.

    --A



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center