webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

how to find the new line character

  • 1.  how to find the new line character

    Posted Thu October 04, 2007 01:50 PM

    HI to all
    could u plz tell me how to find the new line character and it shoud replace with other character
    suppose i have a list strings.i want to pass the input as a string .now it is a string.how to find the new line char with in the strings.how could i convert it into other char.
    i used pub.string.replace service and passed the input string and in the substring parameter i have passed the and in the replace string i passed \ctrf char.but i am not getting output with what i want .could any one plz tell me what is the serivice to find the new line char and it should replace with \crlf char.

    Thanks & Regrds

    kishore


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 2.  RE: how to find the new line character

    Posted Fri October 05, 2007 02:04 PM

    you can create a java service which generate the newline caractere :

    IDataCursor pipelineCursor = pipeline.getCursor();
    IDataUtil.put( pipelineCursor, “crlf”, “\r\n” );
    pipelineCursor.destroy();

    :wink:


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 3.  RE: how to find the new line character

    Posted Fri October 05, 2007 02:18 PM

    OR
    you can use the pub.string.replace service. In the replaceString >>>right click>>>Use large editor>>>hit enter. Thats your new line.

    kerni


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 4.  RE: how to find the new line character

    Posted Fri October 05, 2007 05:08 PM

    Please be aware that end-of-line is indicated differently on different platforms. CRLF is not a “newline” character. It’s a character pair consisting of a carriage return (0x0d) and a linefeed (0x0a) that indicates end-of-line in Windows. Linefeed and newline are synonomous.

    Windows: carriage return, linefeed (newline)
    Unix: linefeed (newline)
    Mac: carriage return

    Either technique above will work IF the data you’re doing the search and replace on contains a CRLF pair. If the data you’re working with contains only CR or only LF then those techniques will not work.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 5.  RE: how to find the new line character

    Posted Tue March 12, 2013 03:18 AM

    Hi,
    Does anyone have any tips for converting Unix linefeed character to Windows CRLF ???

    Cheers,
    David


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 6.  RE: how to find the new line character

    Posted Tue March 12, 2013 07:13 AM

    I’ve been playing around with pub.string:replace and have discovered something funny.

    If I specify “\x0a” for search string and then open larger editor for replace string and hit enter 2 or 3 times.

    If source data only contains Unix Linefeed characters “0x0a”, then the replaced values are multiples of “0x0a”.

    But, if source data contains at least one Windows CRLF (“0x0d”“0x0a”), then all Unix Linefeed characters are replaced with CRLF.

    I’m using a hex editor to confirm the contents of the data both before and after and the results are consistent.

    Has anyone else experienced this ??

    Cheers,
    David


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 7.  RE: how to find the new line character

    Posted Mon March 18, 2013 12:14 PM

    Hi David,

    If your intention is to convert a file from unix to windows format, thats not a right way to do it. I would prefer to execute a command ‘unix2dos’ which will convert efficiently parsing or replace after reading the file.

    My 0.02$,
    Niteesh


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 8.  RE: how to find the new line character

    Posted Thu May 07, 2015 09:46 PM

    Thanks Kerni and guys
    I had a similar requirement
    had to load CSV file did the flat file dictionary and schema with no record identifier
    But had to remove the header record from the string before loading it to flatfile.

    Sample input

    EmployeeId,EmployeeName,DOJ,City,Department CR LF
    1234,QWERTY,12-08-2013,Banaglore,GHT CR LF
    1235,PQRSTUV,12-08-2013,Banaglore,IMBT CR LF
    1239,HOWAREU,19-08-2013,Banaglore,FGTH CR LF
    1240,IMFINE,19-08-2013,Chennai,GCS CR LF
    1236,HIHELLO,12-08-2013,Banaglore,QWER CR LF

    Output
    1234,QWERTY,12-08-2013,Banaglore,GHT CR LF
    1235,PQRSTUV,12-08-2013,Banaglore,IMBT CR LF
    1239,HOWAREU,19-08-2013,Banaglore,FGTH CR LF
    1240,IMFINE,19-08-2013,Chennai,GCS CR LF
    1236,HIHELLO,12-08-2013,Banaglore,QWER CR LF

    would have been nice feature if we could drop records or skip records using the delimiter while loading the data into ffData using the pub.flat:convertToValues.
    anyways all good, thanks


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 9.  RE: how to find the new line character

    Posted Fri May 08, 2015 03:59 PM

    May be a feature request list to SAG :smiley:

    HTH,
    RMG


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 10.  RE: how to find the new line character

    Posted Tue April 12, 2016 04:19 AM

    Has anyone found a way to handle removing newlines nicely?

    I am trying to remove all newlines in some of my strings, using string.replace and hitting enter in large text editor, as bove. My results look good when displayed in the Results pane, with no new lines. However if I use Flow to save this to a file and open it (Linux) or if I just copy and paste from the Results into Notepad++ (Windows), I find that the newlines appear. Looking with a hex viewer, it appears that there are 0x0a characters present.

    I have tried using another string.replace to search for “\x0a” but this seems to have no effect. Tried a bunch of other combinations with “\x0d0a”, “\x0d”, etc but had no luck so far.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 11.  RE: how to find the new line character

    Posted Tue April 12, 2016 04:34 AM

    Probably use System.getProperty(“line.separator”) to get line separator relative to environment before replace


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 12.  RE: how to find the new line character

    Posted Fri April 15, 2016 07:12 AM