string-concatenation

Concatenating variables in Bash [duplicate]

耗尽温柔 提交于 2019-12-03 04:04:41
问题 This question already has answers here : How to concatenate string variables in Bash (30 answers) Closed last year . stupid question no doubt, I'm trying to add a variable to the middle of a variable, so for instance in PHP i would do this: $mystring = $arg1 . '12' . $arg2 . 'endoffile'; so the output might be 20121201endoffile , how can I achieve the same in a linux bash script? 回答1: Try doing this, there's no special character to concatenate in bash : mystring="${arg1}12${arg2}endoffile"

Python .join or string concatenation

不打扰是莪最后的温柔 提交于 2019-12-03 03:45:35
问题 I realise that if you have an iterable you should always use .join(iterable) instead of for x in y: str += x . But if there's only a fixed number of variables that aren't already in an iterable, is using .join() still the recommended way? For example I have user = 'username' host = 'host' should I do ret = user + '@' + host or ret = '@'.join([user, host]) I'm not so much asking from a performance point of view, since both will be pretty trivial. But I've read people on here say always use

Android StringBuilder vs String Concatenation

孤人 提交于 2019-12-03 02:08:21
I was reading this documentation page, http://developer.android.com/reference/android/util/Log.html . The section here caught my eye: Tip: Don't forget that when you make a call like Log.v(TAG, "index=" + i); that when you're building the string to pass into Log.d, the compiler uses a StringBuilder and at least three allocations occur: the StringBuilder itself, the buffer, and the String object. Realistically, there is also another buffer allocation and copy, and even more pressure on the gc. That means that if your log message is filtered out, you might be doing significant work and incurring

How to Concatenate String in Objective-C (iPhone)? [duplicate]

杀马特。学长 韩版系。学妹 提交于 2019-12-03 00:01:36
This question already has answers here : Shortcuts in Objective-C to concatenate NSStrings (30 answers) Possible Duplicate: How do I concatenate strings in Objective-C? Firstly, the platform is iPhone and label.text changes the label displayed. Consider this scenario: I've an array of integers. And I want to display it on the screen. Here's my take on it: -(IBAction) updateText: (id)sender { int a[2]; a[0]=1; a[1]=2; a[2]=3; for (int i=0; i<=10;i++) label.text = [NSString stringByAppendingString: [NSString stringWithFormat: @"%i", a[i]]]; } As you can probably see, I'm pretty confused. Pls pls

How to use a variable when returning response in policy definition?

旧街凉风 提交于 2019-12-02 20:13:52
问题 I'm configuring inbound policies in an instance of Azure API Management. First, I set a variable: <set-variable name="var1" value="" /> Then I send a request <send-request mode="new" response-variable-name="var1" timeout="20" ignore-error="false"> Which returns a JSON. When testing I get the following message in trace tab: GET request to 'https://my-api.azure-api.net/api/data' has been sent, result stored in 'var1' variable. I guess the send-request policy works and the result is stored in

Concat strings in a shell script [duplicate]

时光怂恿深爱的人放手 提交于 2019-12-02 17:52:01
This question already has an answer here: How to concatenate string variables in Bash 30 answers How can I concat strings in shell? Is it just... var = 'my'; var .= 'string'; ? How about this: var="${var}string" dldnh It depends on the shell, but since question was tagged bash: var='my' var=$var'string' No. For various reasons. # most sh-compatible shells var="my" var="$var string" # advanced shells var="my" var+=" string" 来源: https://stackoverflow.com/questions/9445259/concat-strings-in-a-shell-script

Ways of concatenating string in a prepared statement [duplicate]

纵然是瞬间 提交于 2019-12-02 16:53:13
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 3 years ago . I have a web application that needs to be stored its data on specific tables depending on the user's input. e.g. if a user input Code "A" their data will be saved to DatabaseA, while if a user input Code "B", the data will be saved to DatabaseB. I need to know if there is way to manipulate the prepared statement in order to just concatenate the code into the end of

How do I concatenate the string elements of my array into a single string in C?

Deadly 提交于 2019-12-02 14:51:42
I have an array of strings and I would like to create a new string that is a concatenation of all the array elements. Any help is appreciated, thanks #include <stdio.h> #include <stdlib.h> #include <string.h> char *concatenate(size_t size, char *array[size], const char *joint){ size_t jlen, lens[size]; size_t i, total_size = (size-1) * (jlen=strlen(joint)) + 1; char *result, *p; for(i=0;i<size;++i){ total_size += (lens[i]=strlen(array[i])); } p = result = malloc(total_size); for(i=0;i<size;++i){ memcpy(p, array[i], lens[i]); p += lens[i]; if(i<size-1){ memcpy(p, joint, jlen); p += jlen; } } *p

Ways of concatenating string in a prepared statement [duplicate]

99封情书 提交于 2019-12-02 12:42:20
This question already has an answer here: What is a NullPointerException, and how do I fix it? 12 answers I have a web application that needs to be stored its data on specific tables depending on the user's input. e.g. if a user input Code "A" their data will be saved to DatabaseA, while if a user input Code "B", the data will be saved to DatabaseB. I need to know if there is way to manipulate the prepared statement in order to just concatenate the code into the end of the prepared statement string. I have 3 tables, MachineProblem2A,2B,and 2C. is there a way to just simply concatenate the code

Where is the new Object of String created when we concat using + operator

一曲冷凌霜 提交于 2019-12-02 05:34:36
问题 I know this might be quite basic and probably pretty straight forward but i cannot clearly understand what will happen in this situation, so, here it goes. In the following code: String str1 = "Hello"; String str2 = "World"; String str3 = new String("HelloWorld"); String str4 = str1 + str2; i know that str1 and str2 will create an object "Hello" and "World" respectively inside the String Constant Pool . While for str3 a new object is created outside the String Constant Pool which is pointing