|
When using toString() , Double adds commas (5143 is printed as 5,143). How to disable the commas?
Started by Erik Sapir on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
));
(as suggested by others) just replace the comma in the string that you get
Set the locale on load of your.
|
|
I have a string that sometimes has commas seperating the number like 1,500 and I need to convert this to an Int, currently it is throwing an exception, can someone tell me how to fix this so that sometimes I may input numbers with commas and other times...
Started by Emil on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Some use comma as decimal position instead of thousands separator), then just ....
If you don't have to worry about rules for various countries (eg .
You can do replace(';', '') before you convert it to int .
Remove commas before convertion.
|
|
I have a string vaguely like this:
foo,bar,c;qual="baz,blurb",d;junk="quux,syzygy"
that I want to split by commas -- but I need to ignore commas in quotes. How can I do this? Seems like a regexp approach fails; I suppose I can manually scan and enter ...
Started by Jason S on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
After you split on comma....
Baz,blurb" > d;junk="quux,syzygy"
In other words: split on the comma only if that comma has, ignore white spaces ", "+ // match a comma "(?= "+ // start positive look ahead " ( "+ // start group.
|
Ask your Facebook Friends
|
This is what I am trying to do:
1 - I have an array with a string.
$photographer_array = "'Alberto Korda', 'Annie Leibowitz', 'Ansel Adams'";
2 - I am trying to populate an array with that string.
array($photographer_array);
What it is doing is creating...
Started by Chris on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
While there are commas in your $photographer_array variable, they are considered.
If you've got access to PHP >= 5.3.0, then you can use str_getcsv , which parses a comma by commas.
|
|
I need a regexp to split a string by commas and/or spaces, but ignore hyphenated words -- what's the best way to do this?
so, for example -- I'd like this ...
"foo bar, zap-foo, baz".split(/[\s]+/)
to return
["foo", "bar", "zap-foo", "baz"]
but when I...
Started by rsturim on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Characters:
"foo bar, zap-foo, baz".split(/[^\w-]+/)
Or you can split only on whitespace and commas using.
|
|
Is there a way to have rails print out a number with commas in it?
For example, if I have a number 54 .34, I can run <%= number.function %>, which would print out "54,000,000.34"
thanks!
Started by Jess on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
For example:
<%= ....
Number_with_delimiter(98765432.98, :delimiter => ",", :separator => ".") # => 98,765,432.98
You want the number_with_delimiter method .
The method you are looking for is number_with_delimiter.
Yes, use the NumberHelper.
|
|
I need a regex that converts commas to spaces. I know this is super simple, but i do not know regex. thanks.
tag1, tag2, tag3, tag4,tag5 tag6
to
tag1 tag2 tag3 tag4 tag5 tag6
thanks
Started by laxj11 on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Tag6');
If some of your tags without commas between them have more than one space, you could use.
|
|
I am trying to print an integer in Python 2.6.1 with commas as thousands separators. For example, I want to show the number 1234567 as "1,234,567". How would I go about doing this? I have seen many examples on Google, but I am looking for the simplest...
Started by mikez302 on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
D%s" % (x, result)
Recursion is useful for the negative case, but one recursion per comma seems.
|
|
How can I parse a float scanned from a sheet as text, containing commas?
txt = "1,903.44" value = float(txt) # This fails due to ',' in string
UPDATE: Sorry I wasn't clear. I'm using jython 2.5, which doesn't have the locale module.
Started by gregturn on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
You could strip the commas:
txt = txt.replace(',', '') value.
Use locale.atof() after locale.setlocale(locale.LC_ALL, '').
Work but it does the trick if you know that commas are your separators.
|
|
I have a mathparser that can do functions like "IntPow(3,2)". If a user pastes "1,000,000" and then adds a plus symbol, making the full equation "1,000,000+IntPow(3,2)" the parser fails because it does not work with numbers that contain commas.
I need...
Started by John Rennemeyer on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
If you read a comma, delete it if the counter is 0, otherwise....
If you read a ')', decrement that counter.
If you read a '(', increment a counter.
The easiest.
But what if a user pastes:
1,000+IntPow(3,000,2,000)
Now the 3,000 is between comma's.
|