How to delete the ends of line ["\n"] in a String before parsing

hi, i'd want to parse a String with Regex/Pattern.
This String contains ends of line i want to delete before applying my parsing treatment.
I've tried to do that by replacing the character "\n" with "" :
    // the original text
    String orgTextToParse = new String(buffer);
    //we create a pattern to recognize the ends of line
    String regExpEol = "\n";
    Pattern patternEol = Pattern.compile(regExpEol);
    Matcher matcherEol = patternEol.matcher(orgTextToParse);
    // the new text without end of line
    StringBuffer newTextToParse = new StringBuffer();
    // we replace the "\n" by ""
    while(matcherEol.find()) {
      String REPLACE = "";
      matcherEol.appendReplacement(newTextToParse,REPLACE);
    matcherEol.appendTail(newTextToParse);
    System.out.println("[new string start] " + (newTextToParse.toString()) + " [end of new string]");Is there an appropriate way to delete "\n" ?
(perhaps a method of the Pattern or Matcher classes... ?)
thanx
Edited by: jfact on Dec 29, 2007 11:05 AM
Edited by: jfact on Dec 29, 2007 11:06 AM

The second (optional) argument to Pattern is a set of flags. Take a look at the Javadoc.
The 'genomic' implication is that the EOL is an arbitrary line break for human consumption so it does look like you need to remove the EOL. I would just use replaceAll() since it can be done with one line of code (or just a couple if you pre-compile the regex) without the need for any looping.
line = line.replaceAll("\n","");Edited by: sabre150 on Dec 29, 2007 10:27 AM

Similar Messages

  • How to delete the Cost center line item data

    How to delete the cost center line item data of particular cost center and only one cost center is exisiting for that company code.
    Is there any way to delete the line items in that cost center.
    Can data archiving & deleting can help us..........
    does it have any effect over other cost center data....
    any input needed.........
    regards
    rajesh

    Hi,
    i found 2 reports for you:
    1) CO_TOTAL_WRI - Archiving CO Totals Records   
    2) RKCOITW1     - Archiving CO Line Items: Write Program        
    from 2) is a linlk to customize archiv-parameters
    -> start it with transaction se38 / sa38
    A.

  • How to delete the old schedule line release?

    Hello,
    How to delete the old schedule line release in apo?
    Generally GR has to be carry out  schedule line release  in r/3 which reduces the Schdule line release.
    But i do want do GR against old schdule line release instead i want to delete the old schdule line release.
    Please suggest.
    Regards,
    Sunil Patil

    Sunil ,
    /sapapo/cmds_del  is the tcode to deleted sales scheduling agreement confirmations and releases
    /sapapo/display_conf  is the tcode for displaying sls. sch.agr confirmations and releases
    The above two are in the supply chain collaboration menu
    /sappao/cmds_sc02 is the tcode to delete sales scheduling agreements . This tcode is in the application specific master data menu
    Thanks
    Saradha

  • How to delete the old schedule line release in apo

    How to delete the old schedule line release (from current date) in apo which is having schedule  firmed?
    Please suugest.
    Sunil

    How is it possible to delete old purchasing schedule lines in APO (that do not exist in R/3)?
    Though used successfully before, /SAPAPO/CCR will not reconcile our discrepancy in this case.
    Thanks in advance,
    Jim

  • How to delete the commented out lines in PC editor of a SAP Script?

    Hi Experts,
    I hv lot of commentde out code in the PC editor of a my_SAP_Script.........so, wanna to delete all this commented out code, so, let me know that, Do we hv any option other than manual deletion.
    Currently am doing it by,
    keeping the line totally blank,
    keeping the left small box, where we define paragraph formts,
    going BACK,
    save + activating,
    now, those lines r disappearing!!
    but, let me know, Is there any other MENU/push button optin to delete these lines?
    replies appreciatesd,
    thanq

    [pc editor doc|http://help.sap.com/saphelp_nw2004s/helpdata/en/f4/b49f1b453611d189710000e8322d00/frameset.htm]

  • How to stick the ends of line shapes together?

    Hi, as shown in the picture I mannualy moved three lines to form the shape like this.
    Anybody knows is there a way to stick these three line together? THX

    pangeng wrote:
    Hi, as shown in the picture I mannualy moved three lines to form the shape like this.
    Anybody knows is there a way to stick these three line together? THX
    Pages User Guide knows the answer !
    Yvan KOENIG (VALLAURIS, France) jeudi 22 septembre 2011 15:52:29
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • How to delete the line between the last point and first point?

    How to delete the line between the last point and first point? 
    I want to draw a curve many times, from first point to the end point. and redraw from first point to the end point.But I hope update point by point. but between the end point and the first point,  there is a line. How to delete the line?
    the code is:
    CNiReal64Vector plotData(50);
    m_graph.ChartLength = 50;
    //m_graph.ClearData();
    for (int j = 0; j < 2; j++)
           for (int i=0; i<50; i++)
                   plotData[i] = ((double)rand()/(double)RAND_MAX)*6 + 4;
                   m_graph.GetPlots().Item("Plot-1").ChartXY(i, plotData[i]);
                   Sleep(100);
    Attachments:
    20150605142608.png ‏31 KB

    Hi Kumar,
    I think you can just delete it in the sales order directly, if you are using make-to-order scenario, then there will be special stock left for the sales order as the production has been goods receipt, you need to use MM transaction move the stock to unrestricted use stock. If you are using make-to-stock scenario, there should be no further problem. If you are using assembly order, please try to reject the sales order item to see if it could fullfill your requirement.
    Regards,
    Rachel

  • How to delete the specified line in file?

    How to delete the specified line in file? In case of deleting a specified line in a file, how to do?
    Line 1
    Line 2
    Line 3
    Line 4
    Line 5
    The case is a file including the above content. Now I wanna to delete the "Line 3" and how to realize the action in Java?

    An alternative solution can be :
    import java.io.LineNumberReader;
    import java.io.IOException;
    import java.io.File;
    import java.io.FileReader;
    import java.io.BufferedWriter;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    public class LineDeleter {
    public static void main(String args[]){
    try {
    //suppose you want to delete line 3
         int lineToBeDeleted = 3;
         File f = new File("line.txt");
         long fileSize = f.length();
    //Wrap the FileReader with a LineNumberReader. It will help you
    //identify the lines.
    LineNumberReader lnr = new LineNumberReader( new FileReader(f));
    //Wrap the FileWriter object with BufferedWriter object. Create it with the buffersize
    //equal to the file size.
         BufferedWriter bw = new BufferedWriter(new FileWriter(new File("line1.txt")),(int)fileSize);
    //Wrap BufferedWriter object with PrintWriter so that it allows you
    //to print line by line
    PrintWriter pw = new PrintWriter(bw);
         String s=null;
         while ( (s=lnr.readLine())!=null ){
              System.out.println(s);
              int lineNumber = lnr.getLineNumber();
    //match the line number
              if(! (lineNumber==lineToBeDeleted)){
                   pw.println(s);
              pw.flush();
              lnr.close();
              pw.close();
         catch(Exception e){System.out.println(e);}
    If you want you can rename the line1.txt to the original file name.
    I hope this helps.Good luck!!!!!!

  • I get a message Debug Error:[Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "chrome://ffebayhot/content/lib/Extension.debug.js Line: 366"] using Vista. I don't understand how to delete the "ebay

    Every time I try to use google for a search, I get the following error msg. Debug Error:[Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "chrome://ffebayhot/content/lib/Extension.debug.js Line: 366"]. I saw the solution provided for MS XP, but not for Vista. Also, while I saw the solution, I need more explicit instructions on how to "delete the ebay extension".
    == This happened ==
    Every time Firefox opened
    == When I try to load google from Firefox, I get the error message, Debug Error:[Exception... "Node was not found" code: "8" nsresult: "0x80530008 (NS_ERROR_DOM_NOT_FOUND_ERR)" location: "chrome://ffebayhot/content/lib/Extension.debug.js Line: 366"]

    Tools->Add-ons->Extensions
    At the top of the Firefox window, click on the Tools menu and select Add-ons. The Add-ons window will appear.
    In the Add-ons window, select the Extensions panel.
    Select the add-on you wish to uninstall.
    Click the Uninstall button. When prompted, click Uninstall to confirm.
    Then restart Firefox.
    Read here:
    [[Uninstalling add-ons|#How to uninstall extensions and themes|Uninstalling extensions]]

  • How to delete the horiz line of addresses beneath the address bar

    How to delete the horiz line of addresses beneath the address window. They are not affected by the "delete recent sites" tool.

    Do you mean the tab bar?
    See [[Tabbed browsing]]

  • How To delete the Chosen line from the Table Control

    Hi Friends,
      i am new to Module Pool Programming , i developed a Table Control in input mode and i am getting data also into that table control. my requirement is that i want to delete the current chosen line from that table control. please help me out.

    HI
    GOOD
    GO THROUGH THIS REPORT
    REPORT demo_dynpro_tabcont_loop_at.
    CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.
    DATA: cols LIKE LINE OF flights-cols,
    lines TYPE i.
    DATA: ok_code TYPE sy-ucomm,
          save_ok TYPE sy-ucomm.
    DATA: itab TYPE TABLE OF demo_conn.
          TABLES demo_conn.
    SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.
    LOOP AT flights-cols INTO cols WHERE index GT 2.
      cols-screen-input = '0'.
      MODIFY flights-cols FROM cols INDEX sy-tabix.
    ENDLOOP.
    CALL SCREEN 100.
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'SCREEN_100'.
    DESCRIBE TABLE itab LINES lines.
    flights-lines = lines.
    ENDMODULE.
    MODULE cancel INPUT.
      LEAVE PROGRAM.
    ENDMODULE.
    MODULE read_table_control INPUT.
      MODIFY itab FROM demo_conn INDEX flights-current_line.
    ENDMODULE.
    MODULE user_command_0100 INPUT.
      save_ok = ok_code.
      CLEAR ok_code.
      CASE save_ok.
        WHEN 'TOGGLE'.
          LOOP AT flights-cols INTO cols WHERE index GT 2.
            IF  cols-screen-input = '0'.
              cols-screen-input = '1'.
            ELSEIF  cols-screen-input = '1'.
              cols-screen-input = '0'.
          ENDIF.
      MODIFY flights-cols FROM cols INDEX sy-tabix.
    ENDLOOP.
        WHEN 'SORT_UP'.
          READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
          IF sy-subrc = 0.
            SORT itab STABLE BY (cols-screen-name+10) ASCENDING.
            cols-selected = ' '.
      MODIFY flights-cols FROM cols INDEX sy-tabix.
          ENDIF.
        WHEN 'SORT_DOWN'.
          READ TABLE flights-cols INTO cols WITH KEY selected = 'X'.
          IF sy-subrc = 0.
            SORT itab STABLE BY (cols-screen-name+10) DESCENDING.
            cols-selected = ' '.
      MODIFY flights-cols FROM cols INDEX sy-tabix.
          ENDIF.
        WHEN 'DELETE'.
          READ TABLE flights-cols INTO cols
                                  WITH KEY screen-input = '1'.
          IF sy-subrc = 0.
            LOOP AT itab INTO demo_conn WHERE mark = 'X'.
              DELETE itab.
    ENDLOOP.
          ENDIF.
    ENDCASE.
    ENDMODULE.
    CHANGE THE CODE AS PER THIS LIGIC.
    THANKS
    MRUTYUN

  • How to delete the old code in the EXIT_SAPLRSAP_001

    Hi All,
    In R3 system, I wrote an exit for 2LIS_11_VAHDR  by using T-code CMOD in the function exit EXIT_SAPLRSAP_001 and the code does not meet my requirement today i want to delete the code and i will write the fresh one. now my problem is i am not able to delete the code can any body suggest me how to delete the old code.
    and can we create new project and can we assign to the Enhancement RSAP0001.
    Can anybody suggest me in this
    Thanks in advance......
    Narendra

    Hi Narendra,
    You can put the code in comments, if you don't want to use the old code..You can delete also..But be sure that code belongs to you only..
    SE38>zxrsau01>change-->find out your data source
    Comment(Or can delete) the code starting from WHEN '2LIS_11_VAHDR'. to the end of the code that you have written..
    If you really want to delete the assignment of RSAP0001 to your old project>goto CMOD>your project name>change>delete assigment
    Then create a new project and assign the enhancement RSAP0001 to your new project and write the code in Include 'ZXRSAU01'..
    Hope it helps
    Thanks
    Teja

  • *HOW TO DELETE THE ARCHIVE LOGS ON THE STANDBY*

    HOW TO DELETE THE ARCHIVE LOGS ON THE STANDBY
    I have set the RMAN CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY; on my physical standby server.
    My archivelog files are not deleted on standby.
    I have set the CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default on the Primary server.
    I've checked the archivelogs with the FRA and they are not beign deleted on the STANDBY. Do I have to do something for the configuation to take effect? Like run a RMAN backup?
    I've done a lot ofresearch and i'm getting mixed answers. Please help. Thanks in advanced.
    J

    Setting the Policy will not delete the Archive logs on the Standby. ( I found a thread where the Data Guard product manager says "The deletion policy on both sides will do what you want" ). However I still
    like to clean them off with RMAN.
    I would use RMAN to delete them so that it can use that Policy are you are protected in case of Gap, transport issue etc.
    There are many ways to do this. You can simply run RMAN and have it clean out the Archive.
    Example :
    #!/bin/bash
    # Name: db_rman_arch_standby.sh
    # Purpose: Database rman backup
    # Usage : db_rman_arch_standby <DBNAME>
    if [ "$1" ]
    then DBNAME=$1
    else
    echo "basename $0 : Syntax error : use . db_rman_full <DBNAME> "
    exit 1
    fi
    . /u01/app/oracle/dba_tool/env/${DBNAME}.env
    echo ${DBNAME}
    MAILHEADER="Archive_cleanup_on_STANDBY_${DBNAME}"
    echo "Starting RMAN..."
    $ORACLE_HOME/bin/rman target / catalog <user>/<password>@<catalog> << EOF
    delete noprompt ARCHIVELOG UNTIL TIME 'SYSDATE-8';
    exit
    EOF
    echo `date`
    echo
    echo 'End of archive cleanup on STANDBY'
    mailx -s ${MAILHEADER} $MAILTO < /tmp/rmandbarchstandby.out
    # End of ScriptThis uses ( calls an ENV) so the crontab has an environment.
    Example ( STANDBY.env )
    ORACLE_BASE=/u01/app/oracle
    ULIMIT=unlimited
    ORACLE_SID=STANDBY
    ORACLE_HOME=$ORACLE_BASE/product/11.2.0.2
    ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
    LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    LIBPATH=$LD_LIBRARY_PATH:/usr/lib
    TNS_ADMIN=$ORACLE_HOME/network/admin
    PATH=$ORACLE_HOME/bin:$ORACLE_BASE/dba_tool/bin:/bin:/usr/bin:/usr/ccs/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/usr/lbin:/GNU/bin/make:/u01/app/oracle/dba_tool/bin:/home/oracle/utils/SCRIPTS:/usr/local/bin:.
    #export TERM=linux=80x25 wrong wrong wrong wrong wrong
    export TERM=vt100
    export ORACLE_BASE ORACLE_SID ORACLE_TERM ULIMIT
    export ORACLE_HOME
    export LIBPATH LD_LIBRARY_PATH ORA_NLS33
    export TNS_ADMIN
    export PATH
    export MAILTO=?? your email hereNote use the env command in Unix to get you settings.
    There are probably ten other/better ways to do this, but this works.
    other options ( you decide )
    Configure RMAN to purge archivelogs after applied on standby [ID 728053.1]
    http://www.oracle.com/technetwork/database/features/availability/rman-dataguard-10g-wp-1-129486.pdf
    Maintenance Of Archivelogs On Standby Databases [ID 464668.1]
    Tip I don't care myself but in some of the other forums people seem to mind if you use all caps in the subject. They say it shouting. My take is if somebody is shouting at me I'm probably going to just move away.
    Best Regards
    mseberg
    Edited by: mseberg on May 8, 2012 11:53 AM
    Edited by: mseberg on May 8, 2012 11:56 AM

  • How to count the number of lines dynamically,

    In the below code am trying to read the lines which are selected using a check box, also am categorizing the contents depending on the follow up material.
    after displaying one category contents am displaying a line
    which also counts to a line in the internal table.
    My question is how to count the number of lines(ULINE) displayed dynamically.
    FORM GET_LINES .
      DATA: LV_LINES TYPE I,
            LV_TIMES TYPE I,
            LV_TABIX TYPE SY-TABIX.
      DESCRIBE TABLE IT_REC LINES LV_LINES.
      DO LV_LINES TIMES.
        LV_TIMES = SY-INDEX .
        READ LINE LV_TIMES FIELD VALUE IT_REC-CHECK INTO GV_CHECK.
        IF SY-SUBRC EQ 0 AND GV_CHECK IS NOT INITIAL.
          LV_TABIX =  LV_TIMES.
          READ TABLE IT_REC INDEX LV_TABIX INTO GWA_UPDATE.
          IF SY-SUBRC EQ 0.
            APPEND GWA_UPDATE TO GT_UPDATE.
          ENDIF.
        ENDIF.
      ENDDO.
    ENDFORM.                    " GET_LINES

    In the below code am trying to read the lines which are selected using a check box, also am categorizing the contents depending on the follow up material.
    after displaying one category contents am displaying a line
    which also counts to a line in the internal table.
    My question is how to count the number of lines(ULINE) displayed dynamically.
    FORM GET_LINES .
      DATA: LV_LINES TYPE I,
            LV_TIMES TYPE I,
            LV_TABIX TYPE SY-TABIX.
      DESCRIBE TABLE IT_REC LINES LV_LINES.
      DO LV_LINES TIMES.
        LV_TIMES = SY-INDEX .
        READ LINE LV_TIMES FIELD VALUE IT_REC-CHECK INTO GV_CHECK.
        IF SY-SUBRC EQ 0 AND GV_CHECK IS NOT INITIAL.
          LV_TABIX =  LV_TIMES.
          READ TABLE IT_REC INDEX LV_TABIX INTO GWA_UPDATE.
          IF SY-SUBRC EQ 0.
            APPEND GWA_UPDATE TO GT_UPDATE.
          ENDIF.
        ENDIF.
      ENDDO.
    ENDFORM.                    " GET_LINES
    The display function is:
    FORM DISPLAY_DATA .
      ULINE.
      WRITE :  /1 SY-VLINE, 'check',
                10 SY-VLINE, 'Plant',
               20 SY-VLINE, 'Material number',
               50 SY-VLINE, 'Follow up material',
               70 SY-VLINE, 'Safety stock',
              100 SY-VLINE, 'Partc'.
      ULINE.
      LOOP AT IT_MARC.
        MOVE: IT_MARC-WERKS TO IT_REC-WERKS,
              IT_MARC-MATNR TO IT_REC-MATNR,
              IT_MARC-NFMAT TO IT_REC-NFMAT,
              IT_MARC-EISBE TO IT_REC-EISBE,
              IT_MARC-PARTC TO IT_REC-PARTC .
        APPEND IT_REC.
        CLEAR IT_MARC.
      ENDLOOP.
      DATA: GV_TABIX TYPE SY-TABIX.
      LOOP AT IT_REC.
        GV_TABIX = SY-TABIX.
        READ TABLE GT_TOTAL WITH KEY WERKS = IT_REC-WERKS
                                     NFMAT = IT_REC-NFMAT.
        IF SY-SUBRC EQ 0.
          IT_REC-PARTC = GT_TOTAL-PARTC.
          MODIFY IT_REC INDEX GV_TABIX TRANSPORTING PARTC.
        ENDIF.
      ENDLOOP.
      LOOP AT IT_REC.
        WRITE : /1 SY-VLINE, IT_REC-CHECK AS CHECKBOX,
                10 SY-VLINE, IT_REC-WERKS,
                20 SY-VLINE, IT_REC-MATNR,
                50 SY-VLINE, IT_REC-NFMAT,
                70 SY-VLINE, IT_REC-EISBE,
               100 SY-VLINE, IT_REC-PARTC.
        AT END OF NFMAT.
          ULINE.
        ENDAT.
      ENDLOOP.
      ULINE.
    ENDFORM.                    " DISPLAY_DATA
    Solved

  • Hi, since the last update i find my rented movies remained under rented although unplayable. now i find some, as before the update, are deleting fully - can anyone tell me how to delete the unwatchable covers that remain?

    hi, since the last update i find my rented movies remained under rented although unplayable. now i find some, as before the update, are deleting fully - can anyone tell me how to delete the unwatchable covers that remain?

    bunjamin wrote:
    There is now a new line in BBM that wasn't there before which covers the message that I am typing, so I can't actually see what I am typing.
    Hi bunjamin,
    just go to BlackBerry World, and update all your apps including BBM.
    bunjamin wrote:
    Every time I unlock my phone, my screen enlarges so I can't really see much on the hub/notification screen and it defaults to the hub which it didn't do before).
    you can turn off the magnifying glass :
    device settings >> accessibility >> magnify mode >> OFF
    you can deactivate the "reset to Hub view" :
    hub >> overflow (bottom right button) >> Settings >> Display and actions >> Return to Default View When Idle >> OFF
    bunjamin wrote:
    my ringtone is much softer than it was previously
    yes, BlackBerry has acknowledged this bug in this article from the public knowledge base:
    KB36755 After upgrading BlackBerry 10 OS to version 10.3.1 the volume for notifications is noticed to be significantly lower than in the previous version
    The search box on top-right of this page is your true friend, and the public Knowledge Base too:

Maybe you are looking for

  • Re: Yoga 2 Pro - Auto brightness feature and how to disable in Windows 8.1

    I got my YOGA 2 PRO, and after 15 days (I did not copied my files to it yet!) I already have the screen brightness diming without any control. It seems like it goes brigther and darker alone while I am reading a page at firefox or explorer. I saw the

  • Populating 1D Array, Help with 1 Error

    Hello, I have just about finished a program that implements a .txt file containing a few records. The order is an int customerNumber, string firstName, string lastName, and float balance. The snipplet of code posted below is where I believe the probl

  • Aluminum 2008 MacBook Trackpad issue

    Any ideas as to what may be causing this. I have searched tons of threads, but my issue seems unique. The trackpad on my MacBook suddenly is unresponsive in the middle of it. If I touch the upper most and lower most portions of the trackpad it works

  • Where can I download Flash Player 9 instead of 10?

    I am trying to study some education course from the web and was told that I need to download flash player 9 instead of 10 which is the latest version. Is there a place in Adobe.com where I can download a safe copy? Many thanks.

  • Hyperlink to webpage stored on harddrive (not the net)

    I need to hyperlink to a webpage stored on my hard drive. When i enter the URL Keynote automatically adds "http://" and of course the link won't work. Is there a way around this?