multiline

How to enter a multi-line command

烂漫一生 提交于 2019-11-26 02:17:07
问题 Is it possible to split a PowerShell command line over multiple lines? In Visual Basic I can use the underscore ( _ ) to continue the command in the next line. 回答1: You can use a space followed by the grave accent (backtick): Get-ChildItem -Recurse ` -Filter *.jpg ` | Select LastWriteTime However, this is only ever necessary in such cases as shown above. Usually you get automatic line continuation when a command cannot syntactically be complete at that point. This includes starting a new

C multi-line macro: do/while(0) vs scope block [duplicate]

放肆的年华 提交于 2019-11-26 01:42:44
问题 This question already has answers here : Closed 10 years ago . Possible Duplicates: What’s the use of do while(0) when we define a macro? Why are there sometimes meaningless do/while and if/else statements in C/C++ macros? do { … } while (0) what is it good for? I\'ve seen some multi-line C macros that are wrapped inside a do/while(0) loop like: #define FOO \\ do { \\ do_stuff_here \\ do_more_stuff \\ } while (0) What are the benefits (if any) of writing the code that way as opposed to using

How do I match any character across multiple lines in a regular expression?

拈花ヽ惹草 提交于 2019-11-26 01:18:08
问题 For example, this regex (.*)<FooBar> will match: abcde<FooBar> But how do I get it to match across multiple lines? abcde fghij<FooBar> 回答1: It depends on the language, but there should be a modifier that you can add to the regex pattern. In PHP it is: /(.*)<FooBar>/s The s at the end causes the dot to match all characters including newlines. 回答2: Try this: ((.|\n)*)<FooBar> It basically says "any character or a newline" repeated zero or more times. 回答3: The question is, can . pattern match

Java multiline string

血红的双手。 提交于 2019-11-26 00:23:21
问题 Coming from Perl, I sure am missing the \"here-document\" means of creating a multi-line string in source code: $string = <<\"EOF\" # create a three-line string text text text EOF In Java, I have to have cumbersome quotes and plus signs on every line as I concatenate my multiline string from scratch. What are some better alternatives? Define my string in a properties file? Edit : Two answers say StringBuilder.append() is preferable to the plus notation. Could anyone elaborate as to why they

android ellipsize multiline textview

我是研究僧i 提交于 2019-11-25 23:48:20
问题 I need to ellipsize a multi-line textview. My component is large enough to display at least 4 lines with the ellipse, but only 2 lines are displayed. I tried to change the minimum and maximum number of rows of the component but it changes nothing. 回答1: Here is a solution to the problem. It is a subclass of TextView that actually works for ellipsizing. The android-textview-multiline-ellipse code listed in an earlier answer I have found to be buggy in certain circumstances, as well as being

Multiline strings in JSON

岁酱吖の 提交于 2019-11-25 22:48:22
问题 I\'m writing some data files in JSON format and would like to have some really long string values split over multiple lines. Using python\'s JSON module I get a whole lot of errors, whether I use \\ or \\n as an escape. Is it possible to have multi-line strings in JSON? It\'s mostly for visual comfort so I suppose I can just turn word wrap on in my editor, but I\'m just kinda curious... 回答1: JSON does not allow real line-breaks. You need to replace all the line breaks with \n . eg: "first

Creating multiline strings in JavaScript

旧时模样 提交于 2019-11-25 22:12:53
问题 I have the following code in Ruby. I want to convert this code into JavaScript. what\'s the equivalent code in JS? text = <<\"HERE\" This Is A Multiline String HERE 回答1: Update: ECMAScript 6 (ES6) introduces a new type of literal, namely template literals. They have many features, variable interpolation among others, but most importantly for this question, they can be multiline. A template literal is delimited by backticks : var html = ` <div> <span>Some HTML here</span> </div> `; (Note: I'm

Pythonic way to create a long multi-line string

主宰稳场 提交于 2019-11-25 22:03:54
问题 I have a very long query. I would like to split it in several lines in Python. A way to do it in JavaScript would be using several sentences and joining them with a + operator (I know, maybe it\'s not the most efficient way to do it, but I\'m not really concerned about performance in this stage, just code readability). Example: var long_string = \'some text not important. just garbage to\' + \'illustrate my example\'; I tried doing something similar in Python, but it didn\'t work, so I used \