string-concatenation

String concatenation doesn't work for comma character

别说谁变了你拦得住时间么 提交于 2019-12-06 15:57:16
String concatenation on bash script doesn't work on comma "," character. A="Hello"; B=",World"; C=$A$B echo $C; It prints the output as Hello World Bash version is: GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu) The same code seems to work in here The most likely explanation is that you have $IFS set to , The simplest way around this is to double-quote $C , in which case echo is passed the value unmodified : echo "$C" Also note that you don't need the semicolons to terminate your commands, given that each command is on its own line. To print the current value of $IFS in

How to concatenate variable and string in following scenario in PHP?

≯℡__Kan透↙ 提交于 2019-12-06 15:26:35
问题 I've following PHP code: <?php $rebate_no = 2; echo "<table id='blacklistgrid_$rebate_no' class='table table-bordered table-hover table-striped blacklistgrid'> <tr id='reb$rebate_no_1'> <td> <div class='btn-group'> <select name='product_id_$rebate_no[1]' id='product_id_$rebate_no_1' class='form-control prod_list'> <option value='1'>Alabama</option> <option value='2'>Alaska</option> <option value='3'>Arizona</option> <option value='4'>Arkansas</option> <option value='5'>California</option> <

Ruby on Rails - concatenate strings on save to database upon user clicking create action

混江龙づ霸主 提交于 2019-12-06 15:16:02
问题 Its late and I probably should sleep on this. Easy one I have 3 fields in a form which a user fills in. Once they click the create button these records are saved to the database. Simple. However I want the data from these three fields at the same time to be concatenated together, nothing fancy..and inserted to the database at the same time as the other records. This should reflect back to the user on the show page after they create. So I need an action to concatenate 3 db columns lets say

How to build an HTML table with subtotals using a recursive string concatenation?

六月ゝ 毕业季﹏ 提交于 2019-12-06 07:47:03
问题 I have the next two tables: CREATE TABLE #SalesByStore ( Brand VARCHAR(10), StoreName VARCHAR(50), Sales DECIMAL(10,2) ) CREATE TABLE #SalesByBrand ( Brand VARCHAR(10), TotalSales DECIMAL(10,2) ) I am trying to build an HTML table body using recursive string concatenation, and I need to show the sales by store ordered by brand, and after each group of stores from a same brand show the sales subtotals for that brand, like this: I am doing it the following way: DECLARE @tableBody NVARCHAR(MAX),

Operation overloading in R [duplicate]

ぃ、小莉子 提交于 2019-12-06 03:11:14
问题 This question already has answers here : Making a string concatenation operator in R (5 answers) Closed 5 years ago . What's the most straight forward way of overloading '+' for characters? I have defined '%+%' <- function(...) paste(...,sep="") : str <- "aa"%+%"bb"%+%"cc" #str="aabbcc" But I don't like the syntax. I think str <- "aa"+"bb"+"cc" would be nicer. (I am building long SQL queries to use with RODBC, the usual paste is not very handy in such situations. Any suggestions?) 回答1: I

Merge JavaScript objects

牧云@^-^@ 提交于 2019-12-05 23:59:17
I've read another similiar question on SO but there wasn't a clear answer at that question. I got some JavaScript objects that look like this: var moveJSON = { 'name' : move[0].innerHTML, 'info' : move[1].innerHTML, 'power' : move[2].innerHTML, 'accuracy' : move[3].innerHTML, 'type' : move[4].innerHTML, 'category' : move[5].innerHTML, 'pp_min' : move[6].innerHTML, 'pp_max' : move[7].innerHTML } I need to merge them into one object, that will be send to PHP via AJAX. But first: what's the best way to merge them into a single object (array)? This should work. var array = [] array.push(yourObject

What happens if you remove the space between the + and ++ operators?

偶尔善良 提交于 2019-12-05 05:13:15
EDIT 1 DISCLAIMER: I know that +++ is not really an operator but the + and ++ operators without a space. I also know that there's no reason to use this; this question is just out of curiosity. So, I'm interested to see if the space between + and ++var is required in Java. Here is my test code: int i = 0; System.out.println(i); i = i +++i; System.out.println(i); This prints out: 0 1 which works as I would expect, just as if there were a space between the first and second + . Then, I tried it with string concatenation: String s1 = "s " + ++i; System.out.println(s1); // String s2 = "s " +++i;

How much does Java optimize string concatenation with +?

北战南征 提交于 2019-12-05 03:54:58
I know that in more recent Java versions string concatenation String test = one + "two"+ three; Will get optimized to use a StringBuilder . However will a new StringBuilder be generated each time it hits this line or will a single Thread Local StringBuilder be generated that is then used for all string concatenation? In other words can I improve on the performance for a frequently called method by creating my own thread local StringBuilder to re-use or will there be no significant gains by doing so? I can just write a test for this but I wonder if it might be compiler/JVM specific or something

stringByAppendingFormat not working

﹥>﹥吖頭↗ 提交于 2019-12-05 01:44:42
I have an NSString and fail to apply the following statement: NSString *myString = @"some text"; [myString stringByAppendingFormat:@"some text = %d", 3]; no log or error, the string just doesn't get changed. I already tried with NSString (as documented) and NSMutableString. any clues most welcome. Paul Lynch I would suggest correcting to ( documentation ): NSString *myString = @"some text"; myString = [myString stringByAppendingFormat:@" = %d", 3]; From the docs: Returns a string made by appending to the receiver a string constructed from a given format string and the following arguments. It's

How to concatenate variable and string in following scenario in PHP?

自作多情 提交于 2019-12-04 20:51:48
I've following PHP code: <?php $rebate_no = 2; echo "<table id='blacklistgrid_$rebate_no' class='table table-bordered table-hover table-striped blacklistgrid'> <tr id='reb$rebate_no_1'> <td> <div class='btn-group'> <select name='product_id_$rebate_no[1]' id='product_id_$rebate_no_1' class='form-control prod_list'> <option value='1'>Alabama</option> <option value='2'>Alaska</option> <option value='3'>Arizona</option> <option value='4'>Arkansas</option> <option value='5'>California</option> </select> </div> </td> </tr> </table>"; ?> In above code I'm having issues in concatenation of variable