On 7/7/2011 7:48 AM, /dev/rob0 wrote:
> On Thu, Jul 07, 2011 at 06:44:49AM -0500, Stan Hoeppner wrote:
>> On 7/7/2011 5:58 AM, /dev/rob0 wrote:
>>> The anchors at both ends mean you are safe. You start with ^ and
>>> end with $, so nothing else can sneak in between those.
>>>
>>> A simpler expression to accomplish the same thing:
>>> /^[0-9\.]$/ DUNNO
>>> In English, that says: match a string which contains nothing but
>>> numerals and dots. It matches nonsense strings such as "...", but
>>> would be safe as per your intent to only match bare IP addresses.
>>
>> With that being right anchored, the last character it attempts to
>> match is a dot, no? See a problem there?
>
> The last character before $ is in fact "]" which closes the bracket
> expression defined by the opening "[". Read up on character classes
> and bracket expressions.
what rob0 meant was
/^[0-9.]+$/ DUNNO
For those following at home, the + means "one or more
occurrences of the proceeding", and "special character" rules
are different inside character class brackets, so don't escape
the period with a backslash. As originally presented, the
expression will match a single character string consisting of
any number, a backslash, or a period.
Rob knows all this as well as anyone, but the syntax is arcane
and easy to mess up in quick postings.
This (corrected) expression would also match an all-numeric
string, or a phone number in the fairly common 123.456.1212
format. I don't know if such strings ever show up in reverse
hostnames (certainly never with check_client_access, but maybe
with check_reverse_client_hostname_access). Probably better
to stick with the well-tested
/^([0-9]{1,3}\.){3}[0-9]{1,3}$/ DUNNO
-- Noel Jones