true regexp enhancement

Andreas Ericsson ae at op5.se
Wed Jan 19 09:08:14 CET 2005


Robert Bossecker wrote:
> Hello,
> 
> after turning thousands of lines when trying the 
> use_true_regexp_matching i thought if this
> feature may be enhanced by surrounding the pattern string automatically 
> with "^" and "$"
> so there is no need to cover each string to prevent double matches. This 
> may be
> configurable.
> 
> If i have a host named "linux1" and i have also hosts named "linux10" 
> and "linux11"
> there will be a complain about, that a service for linux10 oder linux11 
> is already defined,
> caused by the service definition for this service when writing
> 
> define service{
>    host_name   linux1
>    service_description   PING
>    check_command   check_ping...
> }
> 
> this will unfortunately math all hosts beginning oder containing "linux1"
> 

That is the expected behaviour and the general idea, letting you use a 
namestandard to define identical services for all of your linux-servers 
(f.e.).

> If the patterns will be surrounded by begin and end patterns there is no 
> need to change thousands of
> definitions.

sed -i 's/\(.*host_name\)\([ \t]*\)\([^ \t]*\)/\1\2^\3$/' services.cfg
You need sed version 4.0.9 or later for the -i switch to work. Prior to 
4.1.1 will clobber your file permissions/owner when you're done.

> Then a match for all hostnames beginning with "linux1" must be written 
> as "linux1.*" which expicitly says i want
> additional characters.
> 

The documentation on use_true_regexp matching states that you need to 
take care. If you enable it, you should circumscribe all your non-regexp 
statements with ^$ yourself.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Lead Developer


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt




More information about the Developers mailing list