line-breaks

When do I use PHP_EOL instead of \n and vice-versa ? Ajax/Jquery client problem

一世执手 提交于 2019-12-17 09:31:41
问题 I have a php parser that split a given string by line-breaks, doing something like this: $lines = explode(PHP_EOL,$content); The parser works fine when working on server side. However, when I pass the content via post by ajax (using jquery's $.post method) the problem arises: line breaks are not recogniezed. So after almost an hour of tests and head-aches I decided to changed PHP_EOL by "\n" and it worked: $lines = explode("\n",$content); Now it works! Damn it I lost so much time! Could

RegEx in Java: how to deal with newline

大兔子大兔子 提交于 2019-12-17 06:37:13
问题 I am currently trying to learn how to use regular expressions so please bear with my simple question. For example, say I have an input file containing a bunch of links separated by a newline: www.foo.com/Archives/monkeys.htm Description of Monkey's website. www.foo.com/Archives/pigs.txt Description of Pig's website. www.foo.com/Archives/kitty.txt Description of Kitty's website. www.foo.com/Archives/apple.htm Description of Apple's website. If I wanted to get one website along with its

PHP Echo Line Breaks

北战南征 提交于 2019-12-17 03:36:07
问题 What's the difference between \n and \r (I know it has something to do with OS), and what's the best way to echo a line break that will work cross platform? EDIT: In response to Jarod, I'll be using ths to echo a line break in a .txt log file, though I'm sure I'll be using it in the future for things such as echoing HTML makup onto a page. 回答1: \n is a Linux/Unix line break. \r is a classic Mac OS (non-OS X) line break. Mac OS X uses the above unix \n . \r\n is a Windows line break. I usually

How to linebreak an svg text within javascript?

半腔热情 提交于 2019-12-17 02:29:08
问题 So here is what I have: <path class="..." onmousemove="show_tooltip(event,'very long text \\\n I would like to linebreak')" onmouseout="hide_tooltip()" d="..."/> <rect class="tooltip_bg" id="tooltip_bg" ... /> <text class="tooltip" id="tooltip" ...>Tooltip</text> <script> <![CDATA[ function show_tooltip(e,text) { var tt = document.getElementById('tooltip'); var bg = document.getElementById('tooltip_bg'); // set position ... tt.textContent=text; bg.setAttribute('width',tt.getBBox().width+10);

How do I create a new line in Javascript?

一笑奈何 提交于 2019-12-17 02:21:02
问题 var i; for(i=10; i>=0; i= i-1){ var s; for(s=0; s<i; s = s+1){ document.write("*"); } //i want this to print a new line /document.write(?); } I am printing a pyramid of stars, I can't get the new line to print. 回答1: Use the \n for a newline character. document.write("\n"); You can also have more than one: document.write("\n\n\n"); // 3 new lines! My oh my! However, if this is rendering to HTML, you will want to use the HTML tag for a newline: document.write("<br>"); The string Hello\n\nTest

How to replace newline or \r\n with <br/>?

别说谁变了你拦得住时间么 提交于 2019-12-17 01:57:25
问题 Trying to simply replace some new lines. Have tried 3 different ways and I get no change: $description = preg_replace('/\r?\n|\r/','<br/>', $description); $description = str_replace(array("\r\n","\r","\n"),"<br/>", $description); $description = nl2br($description); These should all work but I still get the newlines. They are double: "\r\r". That shouldn't make any of these fail right? 回答1: There is already nl2br() function that replaces inserts <br> tags before new line characters: Example

using line breaks in meta tags

﹥>﹥吖頭↗ 提交于 2019-12-13 18:42:29
问题 I want to use line breaks in my website description meta tag. How do I do it, because if I see the source code it will still show <br/> only. Something like this I use in my code: <meta name="description" content="<?php echo $gotAlias ?><br/> abc: <?php echo $got_overallrating ?>.<br/> <a href='www.abc.com'>Visit www.abc.com</a> "> 回答1: Try "\n" instead of <br /> , e.g. <?php echo "first line\nsecond line"; ?> ; 回答2: For use in AddThis meta content tagging, the \n is ignored. So it doesn't

Sending mail with line breaks using QDesktopServices::openUrl

被刻印的时光 ゝ 提交于 2019-12-13 06:25:28
问题 I tried to send an e-mail with a prepared subject, receiver and body using Qt. The mail shall open in the system default mail client. I am testing on Linux with KMail and Qt 5.5. This is the code I intended to use: QDesktopServices::openUrl(QUrl("mailto:?to=test@test.com&subject=Test&body=line1%0D%0Aline2", QUrl::TolerantMode)); The mail window opens, subject and receiver are ok. Unfortunately the line breaks in the body do not work. I also tried <br>, \n, \r\n but none of these worked. I

Javascript / Forcing a line break after the point if I have one word

只谈情不闲聊 提交于 2019-12-13 06:07:39
问题 As in the picture, I would force a line break when I have one word after the dot , for a aesthetic issue, but especially as a matter of good reading. It's possible? http://i.stack.imgur.com/EkcuR.jpg 回答1: This works too (*same situation - you don't want a text break after a single word. My solution to that is to select the first two words, wrap them with a span with a class and don't let that text break): <style> section{ width:500px; float:left; font:14px; } .first-two-words2 { font-style

How to delete line-break in string which is encoded by the function EncodeString with Delphi 7?

我是研究僧i 提交于 2019-12-13 01:26:27
问题 I'am using EncodeString in Delphi 7 to encode strings which load from a source textfile. In the source textfile, every line is one record. Now, I want to use the function EncodeString which is Base64 function to encode every line string and write to a new target textfile. My purpose is one line strings in source textfile should encode to one line encryption strings in target textfile. But every line encode to 3 lines encryption strings. There are several line-breaks made to 3 lines. How can I