numbers

Get multiple numbers from a string

六眼飞鱼酱① 提交于 2019-12-30 11:51:31
问题 I have strings like AS_!SD 2453iur ks@d9304-52kasd I need to get the 2 frist numbres of the string: for that case will be: 2453 and 9304 I don't have any delimiter in the string to try a split, and the length of the numbers and string is variable, I'm working in C# framework 4.0 in a WPF. thanks for the help, and sorry for my bad english 回答1: This solution will take two first numbers, each can have any number of digits string s = "AS_!SD 2453iur ks@d9304-52kasd"; MatchCollection matches =

C# - Excel Number Formatting Issue with International settings

戏子无情 提交于 2019-12-30 11:13:47
问题 I am trying to write to an Excel 2003 spreadsheet using c# 3.5. However I am unable to get this to function correctly across different country settings. The country settings are either English or German. These two settings have different decimal and thousands settings. Everything works fine unless a user has changed the decimal and thousands separators in the International settings of the Options screen. Can anybody help as I feel I can no longer see the wood for the trees and am missing

setter/getter not working for Number literal

女生的网名这么多〃 提交于 2019-12-30 11:08:32
问题 I thougt it would be fun to rewrite my zero padding extension to the Number.prototype into a genuine getter/setter pattern. Not very difficult. I ended up with this code ( addSetter and addGetter are just wrapper functions using prototype.__defineGetter__ / __defineSetter__ . Number.addSetter('leftPad0', function(v){ var len = (String(v).length - String(this).length)+1; this._leftPad0 = new Array(len).join('0')+this; } ); Number.addGetter('leftPad0', function(){ return this._leftPad0; } );

Is there a Perl module for parsing numbers, including ranges?

淺唱寂寞╮ 提交于 2019-12-30 10:59:55
问题 Is there a module, which does this for me? sample_input: 2, 5-7, 9, 3, 11-14 #!/usr/bin/env perl use warnings; use strict; use 5.012; sub aw_parse { my( $in, $max ) = @_; chomp $in; my @array = split ( /\s*,\s*/, $in ); my %zahlen; for ( @array ) { if ( /^\s*(\d+)\s*$/ ) { $zahlen{$1}++; } elsif ( /^\s*(\d+)\s*-\s*(\d+)\s*$/ ) { die "'$1-$2' not a valid input $!" if $1 >= $2; for ( $1 .. $2 ) { $zahlen{$_}++; } } else { die "'$_' not a valid input $!"; } } @array = sort { $a <=> $b } keys (

Sorting divs by number inside div tag and jQuery

只愿长相守 提交于 2019-12-30 10:31:33
问题 I'm trying to sort a list of divs with jQuery. Essentially the list might look like this: <div class="contest_entry"><img src="image.png" /><span class="votes">14</span></div> <div class="contest_entry"><img src="image.png" /><span class="votes">8</span></div> <div class="contest_entry"><img src="image.png" /><span class="votes">2</span></div> <div class="contest_entry"><img src="image.png" /><span class="votes">2</span></div> <div class="contest_entry"><img src="image.png" /><span class=

Sorting divs by number inside div tag and jQuery

有些话、适合烂在心里 提交于 2019-12-30 10:30:04
问题 I'm trying to sort a list of divs with jQuery. Essentially the list might look like this: <div class="contest_entry"><img src="image.png" /><span class="votes">14</span></div> <div class="contest_entry"><img src="image.png" /><span class="votes">8</span></div> <div class="contest_entry"><img src="image.png" /><span class="votes">2</span></div> <div class="contest_entry"><img src="image.png" /><span class="votes">2</span></div> <div class="contest_entry"><img src="image.png" /><span class=

Python password strength [duplicate]

江枫思渺然 提交于 2019-12-30 09:52:17
问题 This question already has answers here : Checking the strength of a password (how to check conditions) (4 answers) Closed 6 years ago . I am programming a password strength code on python and i'm trying to find out if my password ( p ) contains a number, I have found out how to see if it contains upper and lower case letter by p.isupper() or p.islower() . I have also put them two together. My friend has told me how to see if the password only contains number but I need your help now. running

java number exceeds long.max_value - how to detect?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-30 08:32:40
问题 I'm having problems detecting if a sum/multiplication of two numbers exceeds the maximum value of a long integer. Example code: long a = 2 * Long.MAX_VALUE; System.out.println("long.max * smth > long.max... or is it? a=" + a); This gives me -2 , while I would expect it to throw a NumberFormatException ... Is there a simple way of making this work? Because I have some code that does multiplications in nested IF blocks or additions in a loop and I would hate to add more IFs to each IF or inside

How do I check if a string has at least one number in it using Ruby?

寵の児 提交于 2019-12-30 07:58:13
问题 I need to check to see if a string contains at least one number in it using Ruby (and I assume some sort of regex?). How would I do that? 回答1: You can use the String class's =~ method with the regex /\d/ as the argument. Here's an example: s = 'abc123' if s =~ /\d/ # Calling String's =~ method. puts "The String #{s} has a number in it." else puts "The String #{s} does not have a number in it." end 回答2: Alternatively, without using a regex: def has_digits?(str) str.count("0-9") > 0 end 回答3: if

How to display the leading zero's in a number of oracle

╄→尐↘猪︶ㄣ 提交于 2019-12-30 06:50:28
问题 I have an oracle column(artnr) contains a length of 1 which is of type number(9). I want to update the number as following... Example : If number is 0 then it should be 00000 If number is 1 then it should be 00001 If number is 12 the it should be 00012 Remember : here 00000,0000, and 00012 are of number datatypes The following are the methods I have tried but failed.. UPDATE pitb.toestel b SET b.artnr = LPAD (b.artnr, 5, 0) WHERE b.idinventaris = 403743; Failed because Lpad can only be