The main goal
-------------

The desired regex should fail for a given fixed width field if THE CONTENTS OF THE ENTIRE FIELD does NOT match the pattern of:

* an integer
* non-zero
* optional +/- signs
* optional padding in front (e.g., `' 1'`)

My current pattern succeeds in the case that *any* front portion matches the pattern. However it should fail unless the entire string matches this pattern.

Some examples of the kind of strings that *should* match (for a field of width 5; all match results are 5 characters long):

```
'12345' # matches up with '12345'
'+2345678' # matches up with '+2345'
'-2345678' # matches up with '-2345'
' +2345678' # matches up with ' +234'

```

My current attempt looks like this, which works for all of the above examples:

```
>>> re.match('(?= *[[+-]?[1-9][0-9]*]?)(?P<X>.{5})', ' +2-345678').group('X')
' +2-3' # should not work here!

```

However I want the expression to fail on the above match attempt due to the fact that the pattern found in the look ahead is interrupted by a non-integer character; in this case, `-`.

An additional string that is causing a problem is the following one, which should also fail:

```
'     1'

```

This one should fail because there are five spaces at the front prior to the integer. Currently the expression allows any number of spaces. I understand this is because `' *'` allows any number of spaces to occur, but it is not solved by doing `' {0,5}'` instead (results in a match for `' '`).

An additional example that ought to fail: 

```
'    +1'

```

In this case, the numerical character does not appear until the sixth position. Therefore the field of width 5 should not produce a match because the matching string `'....+'` ( where dots are spaces) isn't a valid integer.

Some more details
-----------------

Since "why do you want to do this?" is a typical question around here:

I have line types from a file containing fields of various specified lengths.

Sometimes the line fields are right-aligned, sometimes left-aligned (with the remaining characters padded with spaces). Sometimes fields contain integers (with optional +/- signs), sometimes floats OR integers (with optional +/- and optional decimals), and sometimes an arbitrary string. And for some of these fields, the entire field is allowed to be spaces, while for others they are not allowed to be empty.

All of the above details for any given field are known in advance. That is, for any specific line definition (ie combination of fields described above), I know in advance the order of each field in the line, its width, and the kind of information it contains (int, float, float OR int, or any string), including whether or not it is allowed to be blank.

What I am attempting to do is write a single regex for each line definition with pattern labels (using the `(?P<NAME>EXPR)` syntax) so the results can be accessed by name, like so:

```
m = re.match('(?P<SOMELABEL>SOME_PATTERN)', 'SOME_STRING')
m.group('SOMELABEL')

```

I am having trouble finding a way to prevent my regex from succeeding for a number of these field types and for a number of edge cases that I want it to fail, including the above case.