Pattern: Integer

“Integer” is one of the patterns that you can select on the Match panel. Use this pattern to make a field match an integer number in decimal, hexadecimal, octal, and/or binary notation.

Allowed Integer Formats

Select the number bases (decimal, hexadecimal, octal and/or binary) that this field can use. For each base, you can choose one or more alternatives with or without various prefixes and/or suffixes.

When the field validation mode is set to "loose", the field will allow any selected number base with any selected prefix and suffix. In "average" and "strict" modes, the regex will only accept prefix/suffix combinations with numbers in the correct base.

Limit The Integers to These Ranges

Turn on to allow the field to match only integers in the range or ranges of integers that you specified.

Turn off to allow any integer.

This option has no effect when using the "none" and "loose" field validation modes, which always allow any integer. When using the "average" field validation mode, only the number of digits but not the actual integer values are restricted.

Allow Leading Zeros

Turn on to allow the field to be preceded by one or more zeros beyond the normally required or allowed number of digits when limiting the values accepted by the field.

This option has no effect in the "none" and "loose" field validation modes, which always allow any integer with any number of digits.

Integer Ranges

Type in the integers and/or integer ranges that this pattern is allowed to match when limiting the integers. Use semicolons to delimit multiple integers or ranges. Use two dots to specify a range between two integers. You can specify the integers using any of the integer formats supported by RegexMagic, even those that you aren't allowing for this field. For example: 100b..7;42;0x100..999 matches an integer between 4 and 7, the number 42, or any integer between 256 and 999.

If the ranges you specify include integers like 123 that do not specify whether the notation is hexadecimal, decimal, octal, or binary, then RegexMagic looks at the allowed integer formats. If you allow only one format that doesn't use a prefix or suffix the integer to denote its base, then integers in the ranges that don't denote their base are taken to be in that one format you're allowing. Otherwise, they are taken to be decimal numbers.

Negative numbers are not permitted. If you want to match negative numbers, you can use the "number" field validation pattern instead of the "integer" pattern. Alternatively, you can use a "sequence" field that contains a field using the "literal text" pattern to match the sign followed by the "integer" pattern to match the number.

The ranges are ignored when using the "none" and "loose" field validation modes, which always allow any integer. In "average" mode, only the number of digits is restricted. The field will match any integer with at least as many digits as the minimum value and no more digits than the maximum value. In "strict" mode, the regular expression will limit the field to the exact ranges that you specify, which may result in a very long regular expression.

Examples