[pmwiki-users] Need help writing a simple markup for IP addresses inside of pages

Chris Cox ccox at airmail.net
Sun Oct 15 21:53:45 CDT 2006


I have:

Markup('IPAddy', 'inline',
'/([0-9][0-9]*)\.([0-9][0-9]*)\.([0-9][0-9]*)\.([0-9][0-9]*)/',
'%newwin%[[Network/Ip$1-$2-$3-$4|$1.$2.$3.$4]]%%');

Which works fine.

However on some pages I have references to in-addr.arpa addresses
of the form:

1.2.20.10.in-addr.arpa

So... I tried a markup rule like:

Markup('IPRevAddy', 'inline',
'/([0-9][0-9]*)\.([0-9][0-9]*)\.([0-9][0-9]*)\.([0-9][0-9]*)\.in-addr\.arpa/',
'[[Network/Ip$4-$3-$2-$1|$1.$2.$3.$4.in-addr.arpa]]');

However, the two rules DO step on each other.  I know there is some
fancy way of doing conditional regexp... but I don't even know that
kind of regexp is used by PmWiki in this case.

For example, I tried changing IPAddy to:

Markup('IPAddy', 'inline',
'/([0-9][0-9]*)\.([0-9][0-9]*)\.([0-9][0-9]*)\.([0-9][0-9]*)[^.]/',
'%newwin%[[Network/Ip$1-$2-$3-$4|$1.$2.$3.$4]]%%');

Which is sort of a bad hack which tries to look for the trailing dot...
but the NOT syntax [^.] doesn't even appear to work inside the
expression.

Anybody have a hint as to the best way of automatically locating
IP and in-addr.arpa's with markup and turning them into links?
Thanks,
Chris




More information about the pmwiki-users mailing list