Question: Regular Expression: `/^[1-9][0-9]*$/`

The regexp works as intended on <http://www.phpliveregex.com>

My problem is that it doesn't work when implemented with JS, see my code on <http://jsfiddle.net/LHHU7>

The JS:  

```
$("#mytextbox").on("keypress", function(event) {

var re = /^[1-9][0-9]*$/;
var key = doKey(arguments[0] || window.event);
var char = String.fromCharCode(key);

if (key == 8 || key == 37 || key == 39 || re.test(char)) {
    return true;
}

return false;
});

$('#mytextbox').on("paste",function(e)
{
e.preventDefault();
});

function doKey(event) {
var key = event.keyCode | event.charCode;
return key;
}

```

Test cases expected:  

`0001 fail`  

`11 11 fail`  

`1000 success`  

`1264 success`  

`5001 success`  

What's happening with my code:  

`0001 fail WORKING`  

`11 11 fail WORKING`  

`1000 success NOT WORKING`  

`1264 success WORKING`  

`5001 success NOT WORKING`  

For some reason 0 won't be entered. I've already tried on chrome, with no success. I've tried changing my RegExp multiple times with no different results. I've also tried different implementations on my code, but still no success. 

Please see if you can get it working on my jsfiddle before posting your answers. Thanks!

Answer: 
Based on the pseudo code this should be something like this:

```
for i in range(0, len(data)):   
  for j in range(i, len(data)):
    foo(data[i],data[j])

```

also u can do it with one liner:

```
[foo(data[i],data[j]) for i in range(0, len(data)) for j in range(i, len(data)]

```
This is a good place to use [itertools](https://docs.python.org/3.4/library/itertools.html).

```
import itertools

for (left,right) in itertools.combinations(data,2):
    foo(left,right)

```