Home > Community > Forums > Custom IC SKILL > How to remove the new line character

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 How to remove the new line character 

Last post Mon, Oct 15 2012 2:55 AM by Danilo P. 4 replies.
Started by Danilo P 12 Oct 2012 02:27 AM. Topic has 4 replies and 1176 views
Page 1 of 1 (5 items)
Sort Posts:
  • Fri, Oct 12 2012 2:27 AM

    • Danilo P
    • Not Ranked
    • Joined on Mon, Nov 22 2010
    • Padova, Padova
    • Posts 15
    • Points 240
    How to remove the new line character Reply

     Hi all,

    is there a way to remove the newline character at the end of lines read from files?

    I did it with:

    while(gets(line fileIn)

       if( .... then   mystring = car(parseString(line "\n") ..............)

     Is a skill function available to do that?

    thank you

     

     

     

     

    • Post Points: 35
  • Fri, Oct 12 2012 8:41 AM

    • marcelpreda
    • Top 150 Contributor
    • Joined on Tue, Jan 19 2010
    • Bucharest, Romania
    • Posts 44
    • Points 715
    Re: How to remove the new line character Reply

     Hi,

    from what I know there is no skill function to do it straight forward.

     

    Best Regards,

    Marcel

     

    • Post Points: 5
  • Fri, Oct 12 2012 9:27 AM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,567
    • Points 15,575
    Re: How to remove the new line character Reply

    Hi Danilo,

    I've used the method that you noted, but you might also do something like the following:

      when(rexMatchp("\n$" line)
        line = strncat("" line strlen(line)-1)
      ); when the line ends with a carriage return, remove it
    

     I don't know how this compares with the other approach, in terms of speed/resources, so I'll leave that as an excercise for the interested reader ;-)

    Regards,

    Lawrence.

    • Post Points: 20
  • Mon, Oct 15 2012 12:59 AM

    Re: How to remove the new line character Reply
    Or you could use (in IC61X):

    ; create this pattern once
    cr=pcreCompile("\n")
    ...
    ; as you read in each line
    mystring=pcreReplace(cr line "" 0)

    This is using the Perl Compatible Regular Expression functions, storing the compiled pattern object in a variable, and then using that each time you want to replace carriage returns with nothing.

    Regards,

    Andrew.
    • Post Points: 20
  • Mon, Oct 15 2012 2:55 AM

    • Danilo P
    • Not Ranked
    • Joined on Mon, Nov 22 2010
    • Padova, Padova
    • Posts 15
    • Points 240
    Re: How to remove the new line character Reply

     Thank you all for the suggestions.

    Danilo

    • Post Points: 5
Page 1 of 1 (5 items)
Sort Posts:
Started by Danilo P at 12 Oct 2012 02:27 AM. Topic has 4 replies.