newline

Shell: adding a new line between a given line of text

What this question isn't asking is how to add a new line below or above every line which matches a pattern. What I'm trying to do is add a new line between a pattern that exists on one line. Here is an example. before: Monday:8am-10pm after: Monday: 8am-10pm Thus in this case, insert new line after every 'Monday' patt...

Including new lines in PHP preg_replace function

I'm trying to match a string that may appear over multiple lines. It starts and ends with a specific string: {a}some string can be multiple lines {/a} Can I grab everything between {a} and {/a} with a regex? It seems the . doesn't match new lines, but I've tried the following with no luck: $template = preg_replace( $'/\{a\}([.\n]+)\{...

How to replace multiple newlines in a row with one newline using Ruby.

I have a script written in ruby. I need to remove any duplicate newlines (e.g.) \n \n \n to \n My current attempt worked (or rather not) using str.gsub!(/\n\n/, "\n") Which gave me no change to the output. What am I doing wrong? ...

Is there an equivalent of BufferedReader.readLine() that lets me pick what my end of line characters are?

The Javadoc for BufferedReader.readLine() says: A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed. I need slightly better control than this (e.g. I would like to be able to specify that an end of line is "\r\n", so that an "\n"...

Unix newlines to windows newlines (on Windows)

Does anyone know of a way (say Powershell, or a tool) in Windows that can recurse over a directory and convert any unix files to windows files. I'd be perfectly happy with a way in Powershell to at least detect a unix file. It's easy do this for one single file, but I'm after something a bit more scalable (hence leaning towards a Power...

Newline control characters in multi-byte character sets

I have some Perl code that translates new-lines and line-feeds to a normalized form. The input text is Japanese, so that there will be multi-byte characters. Is it still possible to do this transformation on a byte-by-byte basis (which I think it currently does), or do I have to detect the character set and enable Unicode support? In ot...

Why should files end with a newline?

I assume everyone here is familiar with the adage that all text files should end with a newline. I've known of this "rule" for years but I've always wondered — why? ...

Do line endings distinctions apply for html forms?

I know that the line endings used for files vary depending on the OS. I was wondering, if a user pastes text into a http form input such as a textarea, does the line ending character(s) for what gets sent depend on the OS in the same way? ...

Add a new line to a txt file in MS-DOS

Hello, and thank you for reading. I'm making a .bat file and i'd like it to write ASCII-Art into a txt file. I was able to find the command to append a new line to the file when echoing text, but when I read that text file, all I see is a layout-sign and not a space. I think it would work opening that file with Word or even WordPad, b...

Prevent new line when outputting to console

I've set the buffer size to the window size to get rid of the scroll bar. Now, I'm trying to fill the console with a value, but there is always a new blank line added to the end, which causes the first line to be cleared from the buffer. I know why it's happening, but is there any way that I can prevent it? I've tried moving the buffer...

How can I remove linebreaks with a Perl regex?

when I run: perl -e '$x="abc\nxyz\n123"; $x =~ s/\n.*/... multiline.../; printf("str %s\n", $x);' I expect result to be: str abc... multiline... instead I get str abc... multiline... 123 Where am I going wrong? ...

Newlines in Javascript and PHP5

Hi, I have a CSV string that is embedded within an XML document, which is necessary for a flash chart which uses XML. The problem is that the chart gets the settings from the HTML file through a javascript snippet, like so: <script type="text/javascript"> // <![CDATA[ var so = new SWFObject("/gr/amstock.swf", "line", "100%",...

Read in text file line by line php - newline not being detected

I have a php function I wrote that will take a text file and list each line as its own row in a table. The problem is the classic "works fine on my machine", but of course when I ask somebody else to generate the .txt file I am looking for, it keeps on reading in the whole file as 1 line. When I open it in my text editor, it looks just...

Visual C++ Debug window displaying of CR/LF in Visual Studio 2008

For some time now when I am debugging Visual C++ applications and viewing any CString or char* (or any other ascii char based type) variable in the Local, Auto, or Watch debug windows, the CR/LF characters in my variables are not displayed at all. In other words, if I have a string variable set to "This is a line\r\nThis is another line...

What is a quick way to force CRLF in C# / .NET?

How would you normalize all new-line sequences in a string to one type? I'm looking to make them all CRLF for the purpose of email (MIME documents). Ideally this would be wrapped in a static method, executing very quickly, and not using regular expressions (since the variances of line breaks, carriage returns, etc. are limited). Perha...

How to get UITextView to respect newlines in Interface Builder?

I have a simple app with a UITextView embedded into a UIScrollView. Interface Builder won't let me add multiple newlines for spacing; when I hit return it sees that as "end of input" rather than appending the newline to the UITextView. How can I get it to accept newlines for spacing? ...

Removing carriage return and new-line from the end of a string in c#

Guys how do I remove the carriage return character(\r) and the new line character(\n) from the end of a string? ...

Informix - ALLOW_NEWLINE

Hi there, I understand how ALLOW_NEWLINE works. However I don't understand why the option is there in the first place. I would have thought that having it on permanently would be more useful rather than not. Then you can control when you want newlines to appear by inserting "\n" in your code. Can anyone explain why the option is ...

C++ Press Enter to Continue

This doesn't work: string temp; cout << "Press Enter to Continue"; cin >> temp; ...

What's with the line break variations in C# and ASP.NET? (\r\n vs.\n)

I've been writing code for ASP.NET since the start, and today I encountered something I've never seen before. Typically I've looked for line breaks in C# (when posted in ASP.NET from a textarea, for example) by expecting "\r\n". Now I'm using the MVC framework, and the text coming over the wire from a textarea simply has "\n" for line br...