[wpkg-users] More ways of defining hosts in hosts.xml - end
mscdex
mscdex at gmail.com
Sat Apr 25 21:45:22 CEST 2009
On 4/25/09, Jindřich Vorlíček <vorlicek at zsbartuskova.cz> wrote:
>
> I am not familiar with regex engine.
> Will using the pipe characters work also for IP ranges (that use
> non-regular-expression matching)?
> I think, will work e.g. <host
> id="192.168.0.1-254|192.168.1-2.200-30|192.168.3-4.3" profile-id="common"
> />?
>
>
It probably won't work as you have it there, but ip ranges can also be done
in regex. You should be able to mix ip ranges and static hostnames with no
problem.
There may be other (shorter) ways to go about it, especially for 1-254
ranges which you could probably get by using something simple like \d{1,3}
or similar. For small ranges, you could get by by using pipes, such as
(1|2). So with your IP example, here's what it may look like using regexp:
<host
id="(192\.168\.0\.\d{1,3}|192\.168\.(1|2)\.(2[0-9]|30)|192\.168\.(3|4)\.3)"
profile-id="common" />
I wasn't sure what your intended range was for the second one (200-30), so I
used 20-30 instead. This regexp will match ips such as: 192.168.0.1,
192.168.0.34, 192.168.0.250, 192.168.1.20-192.168.1.30,
192.168.2.20-192.168.2.30, 192.168.3.3, 192.168.4.3.
Feel free to put this or your own custom regexps into an online javascript
regex tester (such as http://tools.netshiftmedia.com/regexlibrary/) to make
sure the expression is being evaluated the way you intended. I believe
standard javascript and WSH jscript regex engines are similar if not almost
the same. Just be sure to prefix with ^ and end the expression with $ when
testing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wpkg.org/pipermail/wpkg-users/attachments/20090425/46a9e012/attachment-0002.html>
More information about the wpkg-users
mailing list