newline

What is a cross platform regex for removal of line breaks?

I am sure this has been asked before, but I cannot find it. Basically, assuming you are parsing a text file of unknown origin and want to replace line breaks with some other delimiter, is this the best regex, or is there another? (\r\n)|(\n)|(\r) ...

Web page does not preserve newlines.

Building a web app that includes several contentEditable divs. The users add stuff to the div's, clicks the save button, which saves all the data from each div to a json object. That goes through JSON.stringify to a mysql database as a TEXT (uploaded with php via mysql_real_escape_string() ). When loaded it goes back to JSON.parse and th...

Placing paragraphs within text fields or labels

How do I place a small paragraph within a text field or label? Do I use code for the new line? I'm using Interface Builder with Xcode. ...

NSLog without new line

Is there any function that does what NSLog does but without the new line at the end? ...

Confused over newlines, Unix and PHP

I am using http://code.google.com/p/parsecsv-for-php/ to parse my text file. Using that I have told it that my delimiter is chr(1) which appears to work, however it is taking line feeds also as record breaks (which I specifically don't want it to do....) By default the script says to look for these as linefeeds: var $linefeed = "\r\n...

How to fix “No newline at end of file” compiler warning for lots of files

I have a huge number of source files that are all lacking a newline at the end. How do I automatically add a newline to the end of each of them? Some may already have a newline, so it should only be added if necessary. I'm probably not looking for code, per se, but just something I can run in Terminal to add the necessary newlines (or ...

[php] replace \n with actual new line character code

Hi all, I'm pulling content from a DB that has been sanitized using mysql_real_escape_string. Accordingly the new line characters now appear as "\n". The issue is that this content is displayed to users inside a < pre > tag so I cannot replace \n with < br/> for instance. I suppose I could replace \n with the actual utf8 character code...

What is newline character -- '\n'

Hi, This is a very basic concept, but something I have never been able to articulate that well. and I would like to try to spell it and see where I go wrong. If I have to, how would I define a "newline character". say if I create a new file in unix(or windows), then does the file store the "end of line" information by inserting a speci...

How to replace many intermediate blank lines with only 1 blank line each..

Hi all, I am learning to use sed and have a hypothetical requirement: bash$ cat states California Massachusetts Arizona Wisconsin I would like the output: (Basically I want only one blank line in between) California Massachusetts Arizona Wisconsin Please suggest ways to do it with sed. Should it use concept of multiline pa...

^M at end of lines when editing in CodeBlocks (I think)

I'm on Ubuntu Linux 10.04. I use vim for most of my development and CodeBlocks for debugging. When I first moved from Windows to Linux, I noticed that vim was showing ^Ms for newlines, and found out that this was a Microsoft thing. However, even after removing them I notice that they sometimes reappear in files (files that I edit in Code...

how to convert NEWLINE into <BR/> with XSLT?

how to convert NEWLINE into <BR/> with XSLT? I have <text> some text with new lines </text> I want to have <p> some text with <br /> new lines </p> ...

How to match newlines with Alex/Haskell

I borrowed the example presented here http://www.haskell.org/alex/doc/html/introduction.html I am trying to make an interpreter for numerical expressions. (literals only, no variables) And I want to have newlines separate two different expressions. Unfortunaltely, when I do this $ignoredWhite = [\t\f\v\r] -- ignored whitespace ...

UITextView: How to set '\n' from an XML-loaded string?

I need to indicated a 'new line' in a string in an XML file I'm loading. If I hard code the string: myTextView.text = [NSString stringWithString:@"Line1 \nLine2 \nLine3"]; It displays: Line1 Line2 Line3 (as expected) But if I put the exact string in my XML file: <someNode string="Line1 \nLine2 \nLine3" /> And then load it in...

Regex: remove line breaks from parts of string (PHP)

I want to remove all the line breaks and carriage returns from an XML file so all tags fit on one line each. XML Source example: <resources> <resource> <id>001</id> <name>Resource name 1</name> <desc>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas nibh magna, fermentum et pretium vel, malesuada sit amet ...

match and replace multiple newlines with a SED or PERL one-liner

I have an input C file (myfile.c) that looks like this : void func_foo(); void func_bar(); //supercrazytag I want to use a shell command to insert new function prototypes, such that the output becomes: void func_foo(); void func_bar(); void func_new(); //supercrazytag So far I've been unsuccessful using SED or PERL. What didn't w...

cleanup newlines in responseText

I found the following code in one of the pages I have to maintain; document.getElementById('dummy').innerHTML = httpRequest.responseText; return document.getElementById('dummy').innerHTML; expecting it to do nothing, I replaced it with return httpRequest.responseText; but then the script choked on the input. It turned out that ther...

xslt produces a result that does not end with a carriage return (newline)

Hi all, I have an xslt script that transforms an xml file to another xml file. The problem I'm having is that the resulting xml file does not end with a newline like a well behaved linux file. I'm using <xsl:output method="xml" indent="yes"/> for the code to be nicely idented. Is there a way to tell xslt that this is Linux mode, and i...

jQuery - convert <br> and <br /> and <p /> and such to new line

jQuery - How do you convert <br> and <br /> and <p /> and such to new line? Does jQuery have a built in br2nl() function - this is for converting new lines tags to user-friendly textfield versions. ...

Trouble with newline character while programming for the iPhone

I'm storing text in a sqlite file and setting the text of a UITextView to be the value of that text. The only problem is that the UITextView isn't honoring the newline character. Instead, it's printing it out as text. Here's an example: Stored in fruit.sqlite and passed to theFruit object: requiredFruit = "apples\n oranges\n pears" ...

Java: Insert newline after every 309th character

Let me preface this by saying that I'm pretty new to Java. I have a file that contains a single line. The size of the file is about 200MB. I need to insert a newline character after every 309th character. I believe I have the code to do this properly, but I keep running into memory errors. I've tried increasing the heap space to no avai...