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

Chris Cox ccox at airmail.net
Mon Oct 16 12:55:24 CDT 2006


Chris Cox wrote:
> 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]]%%');

Not so greedy apparently.  [^.] matches digits... so... needed
to change the last part to [^.0-9]... sigh...




More information about the pmwiki-users mailing list