On Feb 2, 2011, at 4:33 PM, Ken wrote:
>
> I have been having trouble with truncation of data from one field of a
> form. The culprit turned out to be the IS_MATCH() validator, which was
> truncating a valid value to return a shorter valid value. I'm not sure
> whether to call this a bug or just unexpected behavior, but if I had
> trouble with it, someone else may.
>
> The data in question were spreadsheet-style coordinate values with
> letters for rows and numbers for columns, in the range A1 to J10.
> Initially, I used a validator like IS_MATCH('^[A-J][1-9]|[A-J]10$').
> This checks first for the two-character combinations A1 to J9, then
> checks for A10 to J10. If I test this in a web2py shell, it accepts
> and returns the two-character combinations, but it accepts and
> truncates any values ending in 10.
>
> In [1] : vdtr = IS_MATCH('^[A-J][1-9]|[A-J]10$')
This is because the precedence of alternation is very low. If you make the
precedence explicit, your pattern is really:
> vdtr = IS_MATCH('(^[A-J][1-9])|([A-J]10$)')
You can fix it like this:
> vdtr = IS_MATCH('^([A-J][1-9]|[A-J]10)$')