Pattern: IPv4 Address

“IPv4 address” is one of the patterns that you can select on the Match panel. Use it to make a field match a internet address such as 127.0.0.1.

Allowed IPv4 Notations

Select the IPv4 address notations that this field can match. You can choose the common dotted decimal notation, as well as decimal and hexadecimal integer notations.

When the field validation mode is set to "loose", if you select the hexadecimal notation with the h suffix or the 0x prefix and also select the dotted and/or decimal notations, then the field will allow the prefix even when dotted or decimal notation is used. In "average" and "strict" modes, the regex will only allow the prefix or suffix when the address is matched in hexadecimal notation.

Minimum Subnet Mask

If the matched IPv4 addresses must have a subnet mask (the 24 in 192.168.0.0/24), specify the smallest subnet mask you want to allow.

Set the minimum subnet mask to zero to make the subnet mask optional.

Maximum Subnet Mask

If the matched IPv4 addresses must have a subnet mask (the 24 in 192.168.0.0/24), specify the largest subnet mask you want to allow.

Set the maximum subnet mask to zero if you don't want the field to match subnet masks.

Limit The IPv4 Addresses to These Ranges

Turn on to allow the field to match only IPv4 addresses in the range or ranges of addresses 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.

Validate 0..255 in dotted addresses

Turn on if the text may contain dotted numbers like 999.999.999.999 that aren't IPv4 addresses and you want to make sure your regular expression does not match these.

Turn on if all dotted numbers in the text you will be using this regex on are valid IPv4 addresses, meaning there is no need to make the regex exclude things like 999.999.999.999 because they don't occur in the text anyway.

This option only makes a difference when the field validation mode is set to "average" or "strict". Only these modes generate regexes that restrict the 4 numbers in dotted IPv4 notation. If the regex needs to match the full range 0..255 for some or all of the 4 numbers in dotted notation, then turning on this option will generate a long regex that matches the range 0..255 exactly. Turning off this option will generate a short regex that allows any number between 0 and 999.

IPv4 Address Ranges

Type in the IPv4 addresses and/or address ranges that this pattern is allowed to match when limiting the addresses. Use semicolons to delimit multiple integers or ranges. Use two dots to specify a range between two integers. You can specify the addresses using any of the IPv4 address notations supported by RegexMagic, even those that you aren't allowing for this field. You can also use the subnet mask notation to specify a range of addresses. For example: 192.168.0.0/24;134744072;10.0.0.3..10.0.0.7 matches an address between 192.168.0.0 and 192.168.0.255, the address 8.8.8.8, or an address between 10.0.0.3 and 10.0.0.7.

A decimal number like 134744072 without a prefix or suffix is interpreted as a hexadecimal number if you selected to allow the hexadecimal notation without a prefix or suffix and you disallowed the decimal notation. If you selected any other combination of notations, the decimal number is interpreted as a decimal number.

The ranges are ignored when using the "none" and "loose" field validation modes, which always allow any IPv4 address. In "average" mode, the dotted notation restricts each of the 4 numbers separately. This may allow the field to match more IP addresses than you specified. E.g. if you restricted the field to match 8.8.8.8 and 8.8.4.4, in "average" mode it will also match 8.8.8.4 and 8.8.4.8. For the decimal and hexadecimal notations, "average" mode only restricts the number of digits. 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 in all the notations that you allow, which may result in a very long regular expression.

Examples