newline

Problem with newline in JavaScript regexp

Hi, i tried to do not show "SPAM" in string below using that regex: alert("{SPAM\nSPAM} _1_ {SPAM} _2_".replace(/{[\s\S]+}/gm, "")); What i was supposed to see was "~1~ ~2~" (or something like that) but i got just ~2~. Why? ...

C++ remove trailing new line from text file

Is there a way in C++ to remove/trim a trailing new line from a text file? For example content content content content content content <- this line in the text file is empty and needs to go -> ...

How to add newlines or carriage returns to description on facebook graph API

It sounds like a pretty simple question but I can find the answer no where. I have a post from a textarea. and I want to use the current facebook php library to do the following... $description = $_POST['textarea_description']; //magic happens $attachment = array( 'access_token' => $token, 'message' => "$title", 'picture' => "$ima...

Why do I get extra line breaks in the web page I download with Perl?

I'm writing a simple Perl script (on Windows) to download the response of a get request to a url to a file. Pretty straight-forward. Except when it writes to the output file, I get extra line breaks. So like instead of: <head> <title>title</title> <link .../> </head> I get <head> <title>title</title> <link .../> </head> ...

Reading and Writing a new line from a file to another in Python

I'm trying to read from a file and write into another. The problem arises when I'm trying to preserve newlines from the original file to the new one. def caesar_encrypt(orig , shift): enctextCC = open("CCencoded.txt" , 'w') for i in range(len(orig)): for j in range(len(orig[i])): curr = orig[i][j] if ord(cu...

How do make an array that fits string from stdin?

I am trying to use 'gethostbyname'. If I hardcode a host name directly into the function call it works great. However, I am trying to pass user input into this function. I believe my problem may because the array I am passing to the function has many trailing whitespaces. void connectHost(char *hostname) { int n; //This ...

What is the right way to create tabs and line breaks in PHP when using single quotes?

Hi, Seems like a simple question, but I haven't been able to find a solid answer anywhere. I'm outputting a ton of HTML and find escaping "s to be error prone and hard to read, but I also want to have my HTML formatted nicely. Want something like this (though I know this won't worK): echo '<div id="test">\n'; echo '\t<div id="test-s...

Getting the new line character without System.getProperty("line.separator")?

I want to create a text file, than load it up without any newlines or spaces (This is for a simple RPG). So I want to test for all 3 major OS line separators, and than the current OS'(s?) one. I know I can get the current one using System.getProperty("line.separator"), but how can I get Linux, Mac, and Windows line separators and turn ...

Removing leading \n while assaigning to a variable

I have a DB2 query in a shell script which return an integer value, but I am unable to store it in a variable. temp1= echo db2 -x "select max(id) from work.work_tb" I am getting this output when I run it, sh -x test.sh db2 -x select max(id) from work.work_tb echo 50 temp1= 50 So for some reason $temp1 is unable to get the value, ...

In C#, what's the difference between \n and \r\n?

As per subject... ...

how to remove new lines and returns from php string?

A php variable contains the following string: <p>text</p> <p>text2</p> <ul> <li>item1</li> <li>item2</li> </ul> I want to remove all the new line characters in this string so the string will look like this: <p>text</p><p>text2><ul><li>item1</li><li>item2</li></ul> I've tried the following without success: str_replace('\n', '', $st...

Regular expression to replace line feeds with a space only if the break is not in the contents of an HTML attribute

I'm trying to write a regular expression that replaces line feeds between certain areas of a text file, but only on plain text content (i.e. excludes text inside HTML attribute contents, like href) but not having much luck past the first part. Example input: AUTHOR: Me DATE: Now CONTENT: This is an example. This is another example. <a ...

Stop Visual Studio from mixing line endings in files

When opening a text based file in Visual Studio 2010 it will then write my edits with CRLF instead of the line ending format of the original file. How can I stop VS from doing this? Any half decent editor should have this capability. What's worse is that since VS wrote the file with portions in CRLF, it then (when opening the file again...

HTML textarea newline character

I have a text area in HTML where the user can enter text, but when the form is submitted, and its passed to a php script which echo's it, there aren't any newlines. Knowing that HTML does that, I tried doing a preg_replace() before echoing it... echo preg_replace("/\n/", "<br />", $_GET["text"]); but still everything is on one lin...

Adding new line in excel cell generated via html

Hi, I'm trying to generate an excel file using html in php and responding with an excel Content-type. Everything works fine except new lines within a cell . They are not preserved. I've tried ; ; \r\n ,chr(13).chr(10) and it didn't work. I'm trying to get the same result from alt + enter from microsoft Excel . I am generating in a ce...

What is the difference between '\n' or "\n" in C++?

I've seen the new line \n used 2 different ways in a few code examples I've been looking at. The first one being '\n' and the second being "\n". What is the difference and why would you use the '\n'? I understand the '\n' represents a char and "\n" represents a string but does this matter? ...

PHP multiple new lines

I'm a little stuck. How do I remove multiple newlines which are in a row with one newline. There could be anything up to 20 newlines next to each other. For example James said hello\n\n\n\n Test\n Test two\n\n Would end up as: James said hello\n Test\n Test two\n ...

Newline differences in c# vs. JS/HTML

If I have a textarea and I put in a newline, FireFox and IE 7/8 seem to store that as "\n". (i.e. if I do val.match(/\n/) it finds something, but val.match(/\r/) finds nothing) C# of course represents newlines as "\r\n". This leads to problems when we have maximum length restrictions, since every newline is counted as one character in th...