Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2013
    Posts
    1
    Rep Power
    0

    Default delete selected string from all the lines in a text file

    hi all my requirement is to delete a selected string from all the lines and extrct particular lines

    for example
    if the file is
    835 B00099991001 000000000000001ISA*00* *00* *ZZ*87726 *ZZ*B00099991001 *130809*0251*^*00501*080801001*0 *P*:~GS*HP*87726*B00099991001*20130809*0251*809010 02*X*005010X221A1~ST*835*0001~BPR*H*0*C*NON******
    835 B00099991001 000000000000002******20130813~TRN*1*1093356082*141 1289245*000087726~REF*EV*B00099991001~DTM*405*2013 08
    ie each line starts with 835.........
    i need to remove that and extract bprsegment till ~


    i have attached my code please go through it and kindly suggest any changes

    thank you



    i need to extract the bpr and trn segments from the file
    example
    BPR*H*0*C*NON************20130813

    TRN*1*1093356082*1411289245*000087726
    bot the file contains astring in every line which should be delated and then these segments are to be extracted
    i haev attached both my code and the sample file please kindly go through it and kindly suggest any changes
    Attached Files Attached Files
    Last edited by sreelakshmi.459@gmail.com; 09-20-2013 at 08:19 AM.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: delete selected string from all the lines in a text file

    Regular expression
    Use indexOf and substring

  3. #3
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,976
    Rep Power
    5

    Default Re: delete selected string from all the lines in a text file

    Quote Originally Posted by Junky View Post
    Regular expression
    Believe me, the code is full of it. Way, waaaaaaaaaaaaaaaaaaaaay to full of it.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    448
    Rep Power
    6

    Default Re: delete selected string from all the lines in a text file

    Hi,

    Sorry I did not get you. Can you please tell about your requirement briefly with input and output parameters.?
    Mak
    (Living @ Virtual World)

Similar Threads

  1. Get selected text from MS Word,browser,pdf file
    By binhdinh0708 in forum New To Java
    Replies: 2
    Last Post: 04-17-2011, 04:04 PM
  2. Writing multiple lines to text file at once
    By Plex in forum New To Java
    Replies: 14
    Last Post: 11-08-2010, 09:17 PM
  3. How to remove 2 last lines in a text file?
    By Marius in forum New To Java
    Replies: 2
    Last Post: 11-30-2008, 03:54 PM
  4. Adding lines at start and end of the text file
    By phani532 in forum New To Java
    Replies: 5
    Last Post: 08-27-2008, 03:12 PM
  5. Remove duplicate lines from a text file
    By Dirt.Diver in forum New To Java
    Replies: 15
    Last Post: 06-25-2008, 02:08 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
  •