Re: extract a text, from a text file, that is contained between two strings



On Fri, 30 May 2008 11:38:49 -0700 (PDT), Giordano
<mejoro82@xxxxxxxxx> wrote, quoted or indirectly quoted someone who
said :

Can you tell me your best way to
extract a text, from a text file, that is contained between two
strings

example: we have a file which contains these words
<<
Ei fu. Siccome immobile,
dato il mortal sospiro,
stette la spoglia immemore
orba di tanto spiro,
...


I want extract that word contained between the 2 words "la" and
"immemore"

I do this sort of thing alls the time. I use HunkIO.readEntireFile to
get the file into a String in Ram and HunkIO.writeEntireFile to put it
back.

See http://mindprod.com/products1.html#HUNKIO

Just use String.indexOf to find your strings. use the variants of it
that take an starting offset.

Put it back together with concatenation or a StringBuilder.

see http://mindprod.com/jgloss/stringbuilder.html
http://mindprod.com/jgloss/string.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
.



Relevant Pages

  • Re: extract a text, from a text file, that is contained between two strings
    ... extract a text, from a text file, that is contained between two ... stette la spoglia immemore ...
    (comp.lang.java.help)
  • Re: Extracting time from strings
    ... to hurt is in trying to determine the shift times in 24 hr format. ... Some rosters are 14 day, others are 28 although all will start on ... extract the employees name, position and section from the first columns. ... strings to extract the times. ...
    (microsoft.public.excel.programming)
  • Re: Extract text plus "n" characters or date on partial match
    ... Maybe starting from the same code I need to extract dates, first, ... extract the "rmd" strings. ... To extract the rmd strings as you write above, ... Dim i As Long ...
    (microsoft.public.excel.programming)
  • Re: Query on pattern matching
    ... I need to extract few strings from one file and paste it to another file. ... Since i am using spaces as delimiters here, i am facing problems. ...
    (perl.beginners)
  • Re: #value error
    ... I would like to extract those row numbersfrom col B text values that have ... three "/" strings that starts with a matching col A value row number.In my ... error.I am getting these desired results at formula evaluation one step ... >> wildcard) in a column range with a text stringI want extract ...
    (microsoft.public.excel.misc)