comma

Replace 2 commas separated by space with space using php

ε祈祈猫儿з 提交于 2019-12-04 02:41:04
问题 Hi friends am trying to replace two commas separated by space with space using php. Here is my code Suppose for example am having variable like $var = "hello, welcome, , , ," Am using the below code to replace the commas in the above string. $output = preg_replace('/[,\s]+/', ' ', $var); Am getting the following output when am executing the above code hello welcome My required output is hello, welcome Can anyone help me with the above code 回答1: The pattern that you intend to replace is a

do_decimal_point and do_thousands_sep Not Working

落花浮王杯 提交于 2019-12-04 02:31:02
问题 do_decimal_point and do_thousands_sep seem to be completely ignored by my stream. What I want is to do is use a period for my thousands_sep and a comma for my decimal_point in get_money. So I override moneypunct but it is just ignored :( struct punct_facet : public moneypunct<char> { char_type do_decimal_point() const { return ','; } char_type do_thousands_sep() const { return '.'; } }; int main() { istringstream USCurrency("1,234.56 -1,234.56 1.234,56 -1.234,56"); USCurrency.imbue(locale

Write a string containing commas and double quotes to CSV

允我心安 提交于 2019-12-04 02:25:54
I'm trying to produce a Google Shopping feed of 30,000+ items in NetSuite, a CRM system that runs server-side JavaScript that it calls Suitescript 2.0. Essentially, it's just JavaScript with a few more restrictions. I've been tasked with outputting this product feed as a CSV. The problem is that the product descriptions of these items contain variables amounts of commas, double quotes, single quotes and HTML. At first, it was just the commas causing me problems, so after a bit of research, I wrapped the strings I was outputting in double quotes: //This function isn't terribly important, but is

Cannot work out a php str_replace() to remove comma

馋奶兔 提交于 2019-12-04 01:26:52
问题 In a PHP project, I have: $string = "1,555"; str_replace(',', '', $string); echo $string; //is still 1,555 str_replace does not remove the comma. If I var_dump. I get string(5) "1,555" Any ideas? I just simply need to remove the commas so I can compute. 回答1: $string = str_replace(',', '', $string); 来源: https://stackoverflow.com/questions/11525560/cannot-work-out-a-php-str-replace-to-remove-comma

comma separated string to list in r

﹥>﹥吖頭↗ 提交于 2019-12-03 23:17:32
I have a comma separated string in R:- "a,b,c" I want to convert it into a list which looks like this: list("a","b","c") How do I do that? This is a basic strsplit problem: x <- "a,b,c" as.list(strsplit(x, ",")[[1]]) # [[1]] # [1] "a" # # [[2]] # [1] "b" # # [[3]] # [1] "c" strsplit creates a list and the [[1]] selects the first list item (we only have one, in this case). The result at this point is just a regular character vector, but you want it in a list , so you can use as.list to get the form you want. 来源: https://stackoverflow.com/questions/24256044/comma-separated-string-to-list-in-r

D3 remove comma delimiters for thousands

不羁岁月 提交于 2019-12-03 22:22:10
I have a .json with 3 columns where one of them is 'Year'. The column contains only years. No dates!. When I am graphing it on the 'x' axis the years come out with a comma delimiter for thousands. So in the .json the date is this format :"Year":1990 and on the 'x' axis it comes out like that 1,990 I have been trying to figure out how to parse the year but I have no luck so far. I have tried the following: var parseDate = d3.time.format("%y").parse var x = d3.time.scale() .range([0, width]); //further down d3.json("waterData.json", function(error, json) { // Attach Data var data = json.data; //

Bash turning single comma-separated column into multi-line string

Deadly 提交于 2019-12-03 21:12:32
In my input file, columns are tab-separated, and the values inside each column are comma-separated. I want to print the first column with each comma separated value from the second. Mary,Tom,David cat,dog Kevin bird,rabbit John cat,bird ... for each record in the second column ( eg cat,dog ) i want to split record into array of [ cat, dog ] and cross print this against the first column. giving output ( just for this line ) Mary,Tom,David cat Mary,Tom,David dog output for whole file should be be: Mary,Tom,David cat Mary,Tom,David dog Kevin bird Kevin rabbit John cat John bird ... any suggest if

What is the advantage of commas in a conditional statement?

北城余情 提交于 2019-12-03 08:03:49
问题 We can write an if statement as if (a == 5, b == 6, ... , thisMustBeTrue) and only the last condition should be satisfiable to enter the if body. why is it allowed? 回答1: Changing your example slightly, suppose it was this if ( a = f(5), b = f(6), ... , thisMustBeTrue(a, b) ) (note the = instead of == ). In this case the commas guarantee a left to right order of evaluation. In constrast, with this if ( thisMustBeTrue(f(5), f(6)) ) you don't know if f(5) is called before or after f(6) . More

What is the advantage of commas in a conditional statement?

情到浓时终转凉″ 提交于 2019-12-02 21:34:33
We can write an if statement as if (a == 5, b == 6, ... , thisMustBeTrue) and only the last condition should be satisfiable to enter the if body. why is it allowed? Jon Jagger Changing your example slightly, suppose it was this if ( a = f(5), b = f(6), ... , thisMustBeTrue(a, b) ) (note the = instead of == ). In this case the commas guarantee a left to right order of evaluation. In constrast, with this if ( thisMustBeTrue(f(5), f(6)) ) you don't know if f(5) is called before or after f(6) . More formally, commas allow you to write a sequence of expressions (a,b,c) in the same way you can use ;

C++ %f dot instead of comma

一曲冷凌霜 提交于 2019-12-02 20:02:47
问题 I'm reading a file in c++ where floating point numbers (%f) have a dot instead of comma. Each line in the file has 3 numbers like that 1.000 -1.000 0.000 for example. My app does not want to read the number past the dot, so If I do fscanf(file, "%f %f %f\n", &x, &y, &z ); for example x is set to 1, everything else is left on 0 because it only reads to the first dot. I've already read somewhere that I should change the locale using setlocale or something similar but it didn't work out. Could