newline

How to check if text is "empty" (spaces, tabs, newlines) in Python?

How can I test if the string is empty in Python? For example, "<space><space><space>" is empty, so is "<space><tab><space><newline><space>", so is "<newline><newline><newline><tab><newline>", etc. ...

Python - file contents to nested list

Hi All, I have a file in tab delimited format with trailing newline characters, e.g., 123 abc 456 def 789 ghi I wish to write function to convert the contents of the file into a nested list. To date I have tried: def ls_platform_ann(): keyword = [] for line in open( "file", "r" ).readlines(): for value in line....

How can I print text immediately without waiting for a newline in Perl?

I have a computationally expensive task in perl, and would like to inform the user that computation is ongoing by printing out a period after each portion of the computation is completed. Unfortunately, until I print a "\n", none of my periods are printed. How can I address this? ...

br2nl Replace All XHTML/HTML Line Breaks with Newlines in PHP

I am looking for the best br2nl function. I would like to replace all instances of <br> and <br /> with newlines \n. Much like the nl2br function but the opposite. I know there are several solutions in the PHP manual comments but I'm looking for feedback from the SO community on possible solutions. ...

Why do multiline cells in my CSV file appear with a question mark at the end of each line in Excel?

I'm currently working on a project where we'd like to allow a user to export their data to CSV. Some of the data we present has multiple values for a single cell, and so we use the standard CSV method of putting each value on its own line: Column A, Column B, Column C Value A, "Value B1 Value B2", Value C Most of the time this works f...

How to get line count from variable (from MYSQL query)?

My problematic code: testMYSQL=`mysql -u $mysqlUser -p$mysqlPass -h $mysqlHost --skip-column-names --batch -D $mysqlDB -e "SELECT $select FROM $mysqlTable WHERE nameTXT='test';"` $testMYSQL now contains: test test test Then I do: TEST=$(echo $testMYSQL | wc -l) echo "$TEST" I would of thought that would work, but it doesn...

NSString with \n or line break

Does anyone know how to use line breaks in NSString? I need to do something like this - [NSString stringWithFormat:@"%@,\n%@", mystring1,mystring2]; ...

Using sed for introducing newline after each > in a +1 gigabyte large one-line text file

I have a giant text file (about 1,5 gigabyte) with xml data in it. All text in the file is on a single line, and attempting to open it in any text editor (even the ones mentioned in this thread: http://stackoverflow.com/questions/159521/text-editor-to-open-big-giant-huge-large-text-files ) either fails horribly or is totally unusable due...

recent cvs cygwin newline windows problems. How to solve?

Hi all, One of our projects still uses CVS. Recently (sometime in the past year) the Cygwin cvs client (currently using 1.12.13) has given me problems when I update. I suspect the problem stems from windows/unix newline differences. It worked for years without a problem. Here are the symptoms. When I update from the command line, I ...

XmlTextWriter.WriteFullEndElement tags on the same line

I am using an XMLTextWriter to create an XML document dynamically (in VB.Net). I want empty tags to appear like this - <Tag></Tag> and not this - <Tag /> So, I am using WriteFullEndElement to end the element tag. But it is writing out the tag as - <Tag> </Tag> i.e. with a newline character between the tags. The web service reading t...

How do I escape a new line character in a .ini file so that Zend_Config_Ini reads it literally?

I am trying to store a multiple line e-mail in an ini file using PHP/Zend Framework. My string has new lines characters in it, and when I use Zend_Config_Ini to parse the ini file, the new line characters come back escaped, so they are printed out on screen, instead of a line feed. Example: // ini file message = Hi {0},\n\nThis is a te...

C++ new line not translating

First off, I'm a complete beginner at C++. I'm coding something using an API, and would like to pass text containing new lines to it, and have it print out the new lines at the other end. If I hardcode whatever I want it to print out, like so printInApp("Hello\nWorld"); it does come out as separate lines in the other end, but if I r...

REGEX (.*) and newline

How can I fix this? REGEX: //REGEX $match_expression = '/Rt..tt<\/td> <td>(.*)<\/td>/'; preg_match($match_expression,$text,$matches1); $final = $matches1[1]; //THIS IS WORKING <tr> <td class="rowhead vtop">Rtštt</td> <td><img border=0 src="http://somephoto"&gt;&lt;br /> <br />INFO INFO INFO</td> </tr> //THIS IS NOT WORKING...

Prevent python from printing newline

I have this code in Python inputted = input("Enter in something: ") print("Input is {0}, including the return".format(inputted)) that outputs Enter in something: something Input is something , including the return I am not sure what is happening; if I use variables that don't depend on user input, I do not get the newline after for...

php echo doesnt print newlines

Hey ! I started doing a new project in PHP / MySql . The Aim of this project is to manage articles for a magazine that i am the editor of. So the content of the articles, i decided i would store with the "TEXT" column type of MySql Now when i retrieve this column and print it with echo, the newlines are not there. Its all on the sam...

preg_match_all and newlines inside quotes

Another noob regex problem/question. I'm probably doing something silly so I thought I'd exploit the general ingenuity of the SO regulars ;) Trying to match newlines but only if they occur within either double quotes or single quotes. I also want to catch strings that are between quotes but contain no newlines. Okay so there's what i g...

Java RandomAccessFile - dealing with different newline styles?

Hey, I'm trying to seek through a RandomAccessFile, and as part of an algorithm I have to read a line, and then seek backwards from the end of the line E.g String line = raf.readLine(); raf.seek (raf.getFilePointer() - line.length() + m.start() + m.group().length()); //m is a Matcher for regular expressions I've been getting loads ...

C++ printf: newline (\n) from commandline argument

How print format string passed as argument ? example.cpp: #include <iostream> int main(int ac, char* av[]) { printf(av[1],"anything"); return 0; } try: example.exe "print this\non newline" output is: print this\non newline instead I want: print this on newline ...

How to avoid mixed eol-styles in a svn repository

Is there a best practice for preventing mixed eol-styles in a subversion repository. I know that svn:eol-style=native can be set as an auto-prop, but I would have to ensure that it was set for all committers. I'm also reluctant to do a retrospective, repository-wide change of svn:eol-style if there is a less invasive solution. ...

Stripping blank spaces and newlines from strings in C

Hi, I have some input like this: " aaaaa bbb \n cccccc\n ddddd \neeee " And I need to sanitize it like this: "aaaaa bbb cccccc ddddd neeee" Basically: Trim all blank spaces at the beginning and end of the string Strip all new lines Strip all spaces when there is more than one, but always leave ONE space between words I...