FAQ Database Discussion Community


preventing emacs from newline insertion

emacs,newline
How can I prevent emacs23 from inserting a newline after C-u M-! date is executed? Setting (setq-default mode-require-final-newline nil) has somehow no effect....

Java 8 programming: Reading a .ini-file and trying to get rid of newline-characters

java,newline,ini
I'm using Netbeans IDE. For a school project I need to read an .ini-file, and get some specific information. The reason I'm not using ini4j: I have a section that has key values which are the same I have sections that have no key-value inputs that I have to read...

How to Replace a specific char in a Varchar2 on Select

sql,oracle,replace,newline
I have a VARCHAR2 that I want to Select, but it's too long. So, I want to Split it into multiples lines like this. SELECT 'Veuillez adresser toute la correspondance à : Aktiva2 Service Comptabilité : 30 B rue de la Petite Hollande 59700 Marcq-en-Baroeul Tel : 03 20 20...

Newline characters disappear after uploading a txt to a server

javascript,d3.js,newline,xss,plaintext
Can't parse any data from a txt file (not a csv for a reason) when it's uploaded to a server because all the newline characters a apparently gone. d3.js parser that I'm using parseRows does not work properly without them. On a localserver everything seems to be fine. d3.text('fileName.txt', 'text/plain',...

Parsing XML Python

python,xml,parsing,xml-parsing,newline
I am using xml.etree.ElementTree to parse an XML file. I have a problem. I do not know how to obtain a plain text line between tags. <Sync time="4.496"/> <Background time="4.496" type="music" level="high"/> <Event desc="pause" type="noise" extent="instantaneous"/> Plain text <Sync time="7.186"/> <Event desc="b" type="noise" extent="instantaneous"/> Plain text <Sync time="10.949"/> Plain text...

Java - printing one character at a time using recursion

java,recursion,newline
I'm trying to print one character at a time from a string recursively such as: a va ava Java Java o Java lo Java llo Java ello Java Hello Java But my code below: public static String displayStuffR(String x){ return displayStuffR(0,x); } public static String displayStuffR(int i,String x){ if (i<x.length()){...

Can you cout an entered newline character (C++)?

c++,newline
Say I would like to be able to cout something with formatting (i.e. newlines, tabs) #include <iostream> using namespace std; string str; int main() { getline(cin, str); cout << str; } So I would enter something like Hey\nThere to get a newline in between hey and there. However, it spits...

Java - An extra character in my code?

java,char,console-application,newline,scanning
I'm using 3 classes: the Character class, the Scanner class, and the Test class. This is the Character class: public class Character { private char cargo = '\u0007'; private String sourceText = ""; private int sourceIndex = 0; private int lineIndex = 0; private int columnIndex = 0; public Character(String...

New line and dollar sign in Java regular expression

java,regex,newline
I know $ is used to check if a line end follows in a Java regular expression. For the following codes: String test_domain = "http://www.google.com/path\nline2\nline3"; test_domain = test_domain.replaceFirst("(\\.[^:/]+).*$?", "$1"); System.out.println(test_domain); The output is: http://www.google.com line2 line3 I assume that the pattern (\\.[^:/]+).*$? matches the first line, which is http://www.google.com/path, and...

A bash command that adds newlines to *.cpp and *.h (or any specified filetypes)?

bash,append,echo,newline
I tried running echo "\n" >> *.cpp *.h But I got *.cpp: Ambiguous. A simple command would do, but added bonus if it only adds it to non-empty files that don't end with newline already...

How to count empty lines inside a string in javascript

javascript,arrays,regex,newline
I'm trying to count all the empty lines inside a string. My current function kind of works: function count_empty(text) { var regex = /\r\n?|\n/g; var lines = text.split(regex); var sep = []; $.each(lines, function(k, val) { if(!val) { //sentence sep.push(val); } }); return sep.length; } ...but I really think it...

Replace all newlines between “two lines with certain patterns” with a comma in vim

regex,vim,newline
If I have to replace newlines with comma for all lines between Pattern 1 and Pattern 2, how do I do it? From: Pattern 1 abcd edfgads asd adsad ... Pattern 2 to: Pattern 1, abcd, edfgads asd, adsad, ..., Pattern 2 ...

Line breaks in phpStorm are removed

php,ftp,newline,phpstorm
I am using phpStorm to edit some files. They appear fine in phpStorm, but when i open them in notepad everything is on one line. So for example this: <?php include('hello.php'); print 'test'; ?> Will become : <?phpinclude('hello.php');print 'test';?> Obviously, this causes error. Why is this happening and how can...

HTML POST insert line break in parameters

java,html,post,line,newline
currently I am trying to use hilite.me/api to format Java code. It all works ok but the only problem is that \n line breaks seem to be ignored and the output is just one long line. Anyone know how I can properly pass in linebreaks into the POST request. Thanks....

Pass arguments include new line character(\n) into C program from command line

c,command-line,newline
I want to pass a shell code(string) in linux, include new line character as arguments into C program from command line, example : ./myprogram "number=0 \n while [ $number -lt 10 ]; do \n echo $number \n number=$((number + 1)) \n done" if I put this string directly in C...

Laravel 5 adding HTML to email

php,html,email,laravel,newline
I'm currently trying to create a HTML email in Laravel 5 and I have some text (which contains <br/> elements) I want to insert in the email. I use the following piece of code to send the email: Mail::send(array('html' => 'emails.newinvoice'), array('text' => $emailtext), function($message) use ($email, $subject, $contact_company) {...

Selenium IDE: How to verify Contents when it contains a mix of tags and
breaks

javascript,selenium,ide,newline
My goal is to verify the contents of a complicated TD cell. It contains a SPAN tage and many BR tags. I'm restricted to using Selenium IDE for this test. The source text looks like this: <td> <span><b style="whatever">TEXT_1</b></span> <br style="whatever"> TEXT_2 <br style="whatever"> TEXT_3 <br> </td> Neither TEXT_1 /...

java - newline detection in strings

java,string,newline
I know that similar questions have been asked several times, but the answers I saw are either workarounds or simply incorrect. The basic problem is fairly simple: A method gives me a string read from a file and I need to check if this string contains newline. Now to the...

C - Making sure user input is of appropriate length

c,newline,fgetc
Something that I thought that would be pretty basic has me stumped. If I have a char array char menuInput[3]; and do fgets(menuInput,3,stdin);, I can easily check if they entered nothing: if(menuInput[0]=='\n') { printf("******You made no selection.******"); } Or if they entered too many (in this case, more than one)...

Google Apps Script New Line Loss of Formating

email,google-apps-script,newline
I have a google form that gets generic information from the user and saves it all in a sheet. When a new form is submitted, the information is appended together with a new line (\n) command between every new piece of information, and is sent to an email using the...

Notepad++ wierd bug? when replace a huge string

regex,string,newline,notepad
I'm getting a CR LF characters after replacing a huge string with Notepad++. Moreover, The string add a line break in places which I didn't ask. Weird... Here is the print screen : Those CR LF character haven't been there before I was using string replace (or they where hidden?...

Django: show newlines from admin site?

python,html,django,newline,textfield
This is probably very simple. My database objects have a TextField. Now, when I add the contents of the TextFields to an html paragraph, there are no new lines. How can I make Django show those newlines? Thank you!

Unwanted line break in C

c,linux,printf,newline,fgets
I have created a little script in C which displays text in a Linux console, but I found one problem - the script adds a line break at the end of text. I have no idea why, normally I should get line break after /n. #include <stdio.h> #include <stdlib.h> int...

Add new line within textbox and label from code behind c#

c#,asp.net,newline
Here is my code for creating the textbox and label from code int i = 0; Label lbl = new Label(); lbl.Text = "Label - " + i.ToString(); lbl.ID = "Label - " + i.ToString(); TextBox txt = new TextBox(); txt.Text = "txt - " + i.ToString(); data.Controls.Add(lbl); data.Controls.Add(txt); Is...

Remove first line in JSON response

objective-c,json,string,newline
I am using the Google Speech API unofficially. If you send it an audio file saying "Test", it will respond with this: {"result":[]} {"result":[{"alternative":[{"transcript":"test","confidence":0.88845605},{"transcript":"tests"},{"transcript":"the test"},{"transcript":"text"},{"transcript":"Test"}],"final":true}],"result_index":0} I need to remove the first line of this response so my parser will not error out. Is there an official way to remove this...

Erlang, how can I create text file with newlines?

file,erlang,newline,writefile,erl
Somebody knows how can I append a new line in the text file in Erlang language? I want to save this list: Data = ["one", "two", "three"], into the text file with new lines: one two three I tried: write() -> Data = ["1","2","3"], Print = string:join(Data, "\n"), file:write_file("/Documents/foo.txt", [Print])....

Forcing a newline in the css when calling a stylus user function

css,css3,newline,stylus
At this moment i'm using this function for passing different browser engines modification (it's outdated I know, but it's used as an example) vendor(prop, args) -webkit-{prop} args -moz-{prop} args {prop} args vendor('border-radius', '1px 1px 1px 1px') So the output will be: -webkit-border-radius: 1px 1px 1px 1px; -moz-border-radius: 1px 1px 1px...

PHP - checking for unicode characters - doesn't work with newlines?

php,regex,unicode,newline
I'm trying to write a PHP script for some form validation. One of the requirements for a text input is that it must contain at least one unicode character. I wrote this function to check for this. function containsLetters($str) { return preg_match('/\p{L&}+/', $str); } It seemed to work fine for...

Can printing cout << '\n' garble text output?

c++,newline,cout
I have a simple program to test a function I'm writing that detects if a text file for a maze is valid. The only allowed characters are '0', '1', ' ' (space) and '\n' (newline). However, when I execute the code with a sample text file, I get some strange...

Remove new lines after echoing HTML from PHP

php,wordpress,replace,newline
I have a Wordpress function that checks if a user has filled in some fields on his or her profile. If it is filled in, echo its contents, if not: don't. Here is a stripped down version of the fun <ul> <?php if (get_the_author_meta('url',$theID)) : ?> <li class="url"> <a href="<?php...

new line in ajax post json data

ajax,json,post,newline
I have a ajax post $.ajax({ headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, type: 'POST', url: '${contextPath}/sms/schedule', data: '{"id":'+ ($('#idAttribute').val()?$('#idAttribute').val():null) + ',"repId":' + $('#repId').val() + ',"scheduleDate":"' + $('#scheduleDate').val()+ '","scheduleTime":"' + $('#scheduleTime').val() + '","message":"' + $('textarea#message').val() + '"}', success: function (data) { $('#schedule-sms-modal').modal('hide'); window.location.replace("${contextPath}/sms/list"); }, error :...

How to remove both whitespace and new line in Regex

regex,newline,whitespace
I have a text string like: Function: General Business So after "Function:" there is a bit of whitespace, then a new line. I have created an API to a website and need to do some Regex to just get "General Business" as a string. At the moment my regex is...

Splitting text in textarea by new lines (including empty lines) into javascript array

javascript,jquery,arrays,split,newline
I'm trying to split the text inside Splitting textarea data by new lines. My current code works, except for a small requirement: The resulting array must include empty lines as well. <script> $(function(){ var lines = []; $.each($('#data').val().split(/\n/), function(i, line){ if(line){ lines.push(line); } }); console.log(lines); }); </script> <textarea id="data"> I...

Including break line in sed replacement

regex,bash,sed,newline
I've got the following sed replacement, which replaces an entire line with different text, if a certain string is found in the line. sed "s/.*FOUNDSTRING.*/replacement \"text\" for line"/ test.txt This works fine - but, for example I want to add a new line after 'for'. My initial thought was to...

VB.NET New Line not working

vb.net,string,newline
The code in my Else is never executed, though I have new lines in my Log (richtextbox). I tried vbNewLine, Environment.NewLine and vbCrLf.. What am I doing wrong? While (Pos < Log.Text.Length) Ch = Log.Text(Pos) If Ch <> vbNewLine AndAlso Ch <> Environment.NewLine AndAlso Ch <> vbCrLf Then Temp +=...

Need to pass string with newline character from Unix shell script to sql query

shell,unix,scripting,newline,sqlplus
I am using unix shell KSH scripting to do some table cleanup. I have a file "partner.txt" with 5000 line like this >cat partner.txt aaa0000 aaa0001 aaa0002 ... ... aaa5000 Using this file, I am supposed to clean few tables with matching, say agreements of the partners. So i am...

HTML cannot create a new line break

html,newline
I do not understand why I couldn't insert a new line in this simple html code. I tried both the <p> tag and the <br> as well as the <h4>, etc. I know it must be a simple solution but I can't find it. The last sentence must be under...

Getting weird results in array-cleanup function

php,arrays,preg-replace,newline,associative-array
I have an associative array titled $allFeeds (after executing print_r($allFeeds);) as follows: Array ( [0] => Array ( [feed_status] => Vividly dug<br />Hchxhh civic<br />Hchxhh cuffing<br />Viccydyduiggigig<br />Bivucfigigudufyd<br />Chchcfhdhcjcfufhcjvjgjfhg<br />Jfufjfufigijdgdjcj<br />Crucify fix<br />Ogives gif<br />Gucucvi<br />Jfufjfufigijdgdjcj<br />Juicy fiduciary<br />Chchcfhdhcjcfufhcjvjgjfhg<br />Jcjcufufydxy<br />Igufucuducufuf<br...

Can I put strings divided by newlines into an array using the read builtin?

arrays,string,bash,newline,delimiter
I have a variable: var='/path/to/filename.ext /path/to/filename2.ext /path/to/filename3.ext' I want to put all strings separated by a newline in an array: declare -a arr Based on numerous posts here on StackOverflow, I found a couple of ways: # method 1: while loop while read line; do arr+=($line) done <<< "$var" #...

Split data into a new line in oracle but in the same row

sql,oracle,newline
I have Data like this ColumnA ColumnB CloumnC 1 king Dog,cat I want show the data like as shown below in only one row "cat" should be shown in new line in the same row ColumnA ColumnB CloumnC 1 king Dog Cat ...

Why doesn't `“hello\r”.chomp('')` remove `“\r”`?

ruby,newline
Although the Ruby reference manual describes: If $/ is an empty string, it will remove all trailing newlines from the string. "hello\r".chomp('') doesn't remove "\r" as in the following. "hello\r\n".chomp # => "hello" "hello\r".chomp # => "hello" "hello\r\n".chomp('') # => "hello" "hello\r".chomp('') # => "hello\r" Why?...

What is the correct newline to use with text/plain ContentType?

http,newline,content-type
When a webserver claims ContentType: text/plain in an HTTP response can the client assume newlines are '\n', or '\r\n', something else, or should it allow both? What standards specify? I am lost and confused among the standards. RFC 2046 appears to define the 'plain' subtype, but there refers to RFC...

Python: How to write a list of strings on separate lines but withot a blank line

python,file,newline
EDIT: See bottom of post for the entire code I am new to this forum and I have an issue that I would be grateful for any help solving. Situation and goal: - I have a list of strings. Each string is one word, like this: ['WORD', 'LINKS', 'QUOTE' ...]...

BufferedWriter is not writing a new line in a file for a String having “\n” added to it

java,string,swing,newline,bufferedwriter
I was trying some stuff in Swing (Java), but getting very strange results. I am getting a String from JTextArea.getText() method and adding "\n" to it. This resultant string I am writing into a file, using BufferedWriter which is chaining through FileOutputStream to a file. But the new line character...

how to print a certain amount of results on a single line

arrays,perl,count,format,newline
I want to print up to 10 results per line and then after 10 force a new line. How would I do this? This is the code: my @email; my @gender; my @state; while ( <> ) { chomp; my @fields = split /,/; push @gender, $fields[5]; push @email, $fields[3];...

C++ Can an fstream object be set to automatically write a newline on each call to <

c++,newline,fstream
I've created an fstream object to write info to files. I write strings to the new file like fStreamObject << "New message.\n"; because I want each << to print a string to the next line. I want to be able to set a property and make a call like fstreamObject...

Inserting new lines into innerHTML output

javascript,html,tags,newline,line-breaks
If I were to have a string for a variable be var text = "Hello World!" and I wanted to place a new line after the word Hello, I know I can just create a new variable var b = text.replace(" ", "\n"); and console.log(b) will show the text in...

c# adding new lines to a console above old lines

c#,console,newline,lines
static void Main(string[] args) { int top, left; Console.WriteLine(); Console.Write("Type here: "); for (int i = 0; i < 99; i++) { top = Console.CursorTop; left = Console.CursorLeft; Console.SetCursorPosition(0, Console.CursorTop - 1); Console.WriteLine("hi" + Environment.NewLine); Console.SetCursorPosition(left, top); } Console.ReadKey(); } I want the result to have 100 "hi" above...

Newline and / or Carriage Return in Swift String

ios,swift,uitextview,newline,carriage-return
I am attempting to add a Newline or Carriage return in a UITextView. var text = UITextField() text.text = "This is a text \r\n This is a text" The result shows the entire text on one line: This is a text This is a text Is it not possible to...

try to delete LF in python or notepad++ but cannot use “find&replace” to find it by “\n”,

newline,eof
the picture is as the following: I don't know why I cannot locate the LF, so does CRLF! According to the image, there is exactly LF there, but I cannot use notepad++'s find function by "\n" to really find it, so I cannot replace it with blank at all. My...

Regex Match without new line ^M

regex,perl,newline,vi
I have a regex in my perl script which is /Operating System:\s*(.*)/. The line I am matching is Operating System: Windows XP Service Pack 3 however, there is a new line after entered after that line. So the text would be seen as Operating System: Windows XP Service Pack 3^M....

How do I include new lines in a string in Perl?

string,perl,newline
I have a string that looks like this Acanthocolla_cruciata,#8B5F65Acanthocyrta_haeckeli,#8B5F65Acanthometra_fusca,#8B5F65Acanthopeltis_japonica,#FFB5C5 I am trying to added in new lines so get in list format. Like this Acanthocolla_cruciata,#8B5F65 Acanthocyrta_haeckeli,#8B5F65 Acanthometra_fusca,#8B5F65 Acanthopeltis_japonica,#FFB5C5 I have a perl script use strict; use warnings; open my $new_tree_fh, '>', 'test_match.txt' or die qq{Failed to open "update_color.txt" for output:...

What are the safer and correct alternatives to deprecated `Data.ByteString.Lazy.putStrLn` and why?

string,haskell,unicode,io,newline
I wonder why Data.ByteString.Lazy.putStrLn is deprecated, but Data.ByteString.Lazy.putStr and Data.ByteString.Lazy.hPutStr are not? -- | A synonym for @[email protected], for compatibility -- hPutStr :: Handle -> ByteString -> IO () hPutStr = hPut -- | Write a ByteString to stdout putStr :: ByteString -> IO () putStr = hPut stdout --...

Is it possible to test for two new line characters in a row?

c,newline,c89
I'm trying to validate lines in a file with actual content in them, and exiting on cases where there are two empty lines in a row. Can this be done? This code results in fgetc() not catching the double carriage returns/new lines. Code is a snippet from a C89 project,...

How do I replace newlines only between numbers and a sentence?

linux,awk,sed,newline,digits
I want to remove newlines in some special cases. I have this text: 0 15.239 23.917 Reprenem el debat que avui els oferim entorn de les perspectives d'aquest dos mil set. &lt;ehh&gt; Estavem parlant concretament dels temes 30.027 de la seguretat mundial una miqueta de la intervencio 33.519 que And...

C++ cross-compile not handling newline input text file

c++,newline,cross-compiling
For clarity: This is NOT a duplicate of Getting std :: ifstream to handle LF, CR, and CRLF? This IS an extension of C++ cutting off character(s) when read lines from file I state this up front because when I posted the question at C++ cutting off character(s) when read...

Word count not working when entering new line

c#,split,newline
I've been looking at other stack overflow articles regarding similar issues when it comes to word count in C#, but none have helped me when it comes to the pickle I've encountered. I have a textbox that inputs text from a text file. The text is split into three lines...

php files newlines missing [duplicate]

php,ftp,ide,newline
This question already has an answer here: PHP Parse/Syntax Errors; and How to solve them? 10 answers I downloaded php files through ftp. After editing them and uploading them again, I basically always get an error on line 1 with one of my first actions: Parse error: syntax error,...

why after looping there's a newline

c,newline,counter,scanf
so i'm trying to make a penalty kick scorekeeper. i set it to be 5 rounds at first, and when the scores are tied, it will repeat another 5 rounds. the problem is there's seem to be a newline appeared after it. #include <stdio.h> int main() { int penalty2=0,penalty1=0,i=0; char...

Put linebreak/newline in tooltip

jsf,tooltip,newline
I'd like to put a linebreak in a tooltip so that it displays like: Nom: value1 Quality: value2 I tried: 1. <h:outputText title="Nom: #{cntc.value1}&lt;br/&gt;Quality: #{cntc.value1}" /> 2. <h:outputText title="Nom: #{ (''.concat(cntc.value1).concat('&lt;br/&gt;')concat('Quality: ').concat(cntc.value2)}" /> None of them worked for me. It seems that the <br/> isn't being interpreted. How can I...

How to post figures on a new line in php?

php,newline,figure
I want to control when to put figures on a new line in php. I can keep posting figures like so: <A HREF="./images_local/figname.gif"> <img height=196 width=128 src="./images_local/figname.gif"/></A> <A HREF="./images_local/figname2.gif"> <img height=196 width=128 src="./images_local/figname2.gif"/></A> <A HREF="./images_local/figname3.gif"> <img height=196 width=128 src="./images_local/figname3.gif"/></A> But they all post left to right, until they run out...

Xml Document Transform to find and replace values

.net,xml,newline,xdt-transform,xdt
I have an xml document that has a sql query in it. Lets say it looks like this for example: <commandText> Select ProductID, ProductName From Product</commandText> When this gets run through octopack and deployed (via octopus deploy) onto my server it looks like this: <commandText> Select ProductID, ProductName&#xD;&#xA; From Product</commandText>...