There are a couple of slightly different ways of doing this in PCRE:

1) '.*(?i)cfengine.*'

2) '.*(?i:cfengine).*'

The first one turns on the "/i switch for everything after it, so the .* is 
also case-ignored

The second one turns on the "/i switch" only for "cfengine".

There's no difference in this case, but it'd make a differece if you had 
something other than '.*' after 'cfengine' :-)  The '^' isn't needed in any 
event.

-Dan

On May 13, 2011, at 6:08 PM, Jesse Becker wrote:

> On Fri, May 13, 2011 at 08:32:05AM -0400, Mikhail Gusarov wrote:
>> On 05/06/2011 04:33 PM, no-re...@cfengine.com wrote:
>> 
>>> BTW, I think the fact that a "." now matches ANY character rather than any 
>>> character except a newline needs to described in the reference manual.
>> 
>> I have clarified this in reference manual, and updated example and
>> comment for readtcp function as well.
> 
> This may be a more general PCRE question, but is it possible to include
> "modifers" in the regexes? 
> 
> For example, let's say that I want to set a class if the string
> "cfengine" appears in a file, but I don't care about case sensitivity.
> 
> classes:
>       'good_file' expression => regline('^.*cfengine.*', ${testfile});
> 
> I could write out all 265 permutations of "cfengine"
> capitialization ("cfengine", "Cfengine", "cFengine", "CFengine", etc),
> but that's pretty inefficient.
> 
> I could also write '^.*[cC][fF][eE][nN][gG][iI][nN][eE].*', but that's
> just ugly. :)
> 
> What I'd like is a simple way to add a "i" modifier to the regex so that
> I can write the equivilent of:  
> 
>       /^.*cfengine.*/i
> 
> 
> 
> 
> -- 
> Jesse Becker
> NHGRI Linux support (Digicon Contractor)
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to