newline

Using gsub to replace a particular character with a newline (Ruby, Rails console)

Hey there Annoying problem. I am trying to replace all semicolon characters in my Model's description field with newline characters (\n). The database is sqlite. The field is of type text. If I do it manually at the rails console (manually typing the description for a single record using \n for line breaks), the rails console automati...

What the best way to get paragraphs in a WPF textblock? (newline chars?)

Hi, I have some text which has "\r\n" newline markers. I would like to have the newlines in a WPF textblock. I've tried replacing "\r\n" with "& # 13;" (without the spaces), which worked when I set the Text property in XAML, but doesn't seem to work when setting from the C# code-behind. So...what's the standard way to convert "\r\n" to...

Why does my Apache2::Log output replace newlines with \n?

I've set up multiple vhosts under apache2 / mod_perl. I used the ErrorLog directive to get a separate error log for each vhost. This only worked as expected when I used Apache2::Log. 'warn' would only log to the regular error log. So that's all working. Finally. But there's one issue remaining: When I log via $r->log_error, I find that ...

Print CLOB content out as is in Oracle SQL script

Hi, To start with here is the bigger picture of the task I'm trying to do. I need to create a xml file from the results of the particular SQL request and store it in a file on the client computer. For that I have a SQL script that does the DBMS_XMLGen with xslt, which I'm going to run from a command line with sqlplus and pipe the outpu...

PHP regex to limit new lines to a maxmium of two

I'm using this but it's replacing single occurances of a new line with <br/><br/> function nl2br2($string){ $string = preg_replace('/(\r\n){2,}/', '<br/><br/>', $string); //$string = preg_replace('/[\r\n]/', '<br/>', $string); return $string; } It happens with the first pattern. ...

Apache HSSF POI excel doc to tab delimted file

went and got a file that already "works" from here: xls to csv Note, I wanted a tab delimited format, so I just went in and changed "," to "\t" and then removed a bunch of the extra formatting, such as naming the workbook. The problem is, however, that this code I found splits some Excel rows into 2+ lines. These are the rows where I h...

Problem with EOF in C

I'm writing a program which is supposed to read two strings that can contain line breaks and various other characters. Therefore, I'm using EOF (Ctrl-Z or Ctrl-D) to end the string. This works fine with the first variable, but with the second variable, however, this seems to be problematic as apparently something is stuck in the input b...

Determine newline return method in PHP

What would be the best way to detect newline return method in PHP. CR, LF or CR+LF And if possible convert it to specified type. ...

Why is Environment.NewLine showing up as square character?

I'm working with a .Net windows application. On my machine, a form displays Environment.NewLine correctly as a new line. However, on a tester's machine, the same Environment.NewLine is being displayed as a square character. On both of our machines, we have our regional settings temporarily set to French, for testing purposes. How do I s...

Changing std::endl to put out CR+LF instead of LF

I'm writing a program on a Linux platform that is generating text files that will be viewed on, inevitably, a Windows platform. Right now, passing std::endl into a ostream generates the CR character only for newlines. Naturally, these text files look wrong in MS Notepad. 1) Is there a way to change std::endl such that it uses CR+LF f...

Why does my Perl tr/// remove newlines?

I'm trying to clean up form input using the following Perl transliteration: sub ValidateInput { my $input = shift; $input =~ tr/a-zA-Z0-9_@.:;',#$%&()\/\\{}[]?! -//cd; return $input; } The problem is that this transliteration is removing embedded newline characters that users may enter into a textarea field which I want to keep as ...

Insert a Newline in Excel Formula (MacOS)

I am using MS Excel on a Mac. I have a formula. Guests!A1 & " " & Guests!B1 & I WANNA PUT NEWLINE HERE Guests!C1 ... How do you do this???? Thx! ...

How to read lines from a text file one by one with Power Point VBA code?

This code will read a line from a text file: set file = CreateObject("Scripting.FileSystemObject").OpenTextFile("c:\number.txt", 1) text = file.ReadLine MsgBox text How can I make it read repeatedly one line after another from the same file? I guess, I should use a loop here, right? I need it to read the first line from the file at th...

Regex starting with a zero length line and continuing across lines in Java

Hi, I want to match the following: a zero length line, with the match continuing across lines of non-zero length until a particular string is matched in a line. E.g: the match starts with a zero length line and continues until STOP is reached: Some random text I don't care about The match starts at the beginning of this line The match...

Why does this regular expression not match adjacent occurences of newline?

I was trying to write a regexp to replace all occurrences of \n with \r\n unless the \n is already proceeded imediately by a \r. I'm doing this in Ruby 1.8.6 which doesn't support look behind in regexps so I tried: # try to replace \n proceeded by anything other than \r with \r\n str.gsub(/([^\r])\n/, "\\1\r\n") # \\1 is the captured ch...

PHP regex not new line

How do I have a regex statement that accepts any character except new lines. This includes anything but also includes new lines which is not what i want: "/(.*)/" ...

What's the most pythonic way of normalizing lineends in a string?

Given a text-string of unknown source, how does one best rewrite it to have a known lineend-convention? I usually do: lines = text.splitlines() text = '\n'.join(lines) ... but this doesn't handle "mixed" text-files of utterly confused conventions (Yes, they still exist!). Edit The oneliner of what I'm doing is of course: '\n'.join...

How To Use \n In a TextBox

I'm developing a program that I'm using a string(generatedCode) that contains some \n to enter a new-line at the textBox that I'm using it(textBox1.Text = generatedCode), but when I'm running the program, instead of breaking that line I'm seeing a square. Remember that I've set the Multiline value of the textBox to True. ...

Difference between \n and \r?

Whats the difference between \n (newline) and \r (carriage return)? Edited to add: All the answers are fairly predictable, but I'd be interested to know if there are any PRACTICAL differences between \n and \r. Are there places where one should be used over the other? ...

Deleting new lines with regular expression from Ant task

I've posted to 2 forums already (CodeRanch and nabble) and no one has responded with an answer .... so stack overflow ... you are my last hope. All I'm trying to do is delete the "\n" from a file using an Ant task. There simply is a bunch of empty lines in a file and I don't want them there anymore ... here is the code I used .. <re...