I'd forgotten all about that syntax as my more intermediate-to-advanced Perl has gotten a bit rusty. I'm glad to know that works with libpcre. Thanks for the tip!
Justin -----Original Message----- From: Diego Zamboni [mailto:di...@zzamboni.org] Sent: Wednesday, February 17, 2010 3:37 PM To: Justin Lloyd Cc: nwat...@symcor.com; Mark Burgess; Lebel, Marco; help-cfengine@cfengine.org Subject: Re: regcmp help Howdy, PCRE allows you to set the /s flag using (?s) at the beginning of the regex: PCRE_DOTALL If this bit is set, a dot metacharater in the pattern matches all char- acters, including those that indicate newline. Without it, a dot does not match when the current position is at a newline. This option is equivalent to Perl's /s option, and it can be changed within a pattern by a (?s) option setting. A negative class such as [^a] always matches newline characters, independent of the setting of this option. So the example below works as expected (see the change in the "port2" regex). Best regards, --Diego body common control { bundlesequence => { "test" }; } bundle common agent { classes: "all" expression => "any"; } bundle agent test { vars: "reg" string => "OpenSSH"; "str1" string => "SSH-OpenSSH-4.3"; "str2" string => "SSH-OpenSSH-4.3 newline"; classes: "port1" expression => regcmp(".*${reg}.*","${str1}"); "port2" expression => regcmp("(?s).*${reg}.*","${str2}"); # Both DO match reports: port1:: "Port1 match!"; !port1:: "No port1 match!"; port2:: "Port2 match!"; !port2:: "No port2 match!"; } -----Original Message----- From: help-cfengine-boun...@cfengine.org [mailto:help-cfengine-boun...@cfengine.org] On Behalf Of Justin Lloyd Sent: Wednesday, February 17, 2010 3:01 PM To: nwat...@symcor.com; Mark Burgess Cc: Lebel, Marco; help-cfengine@cfengine.org Subject: RE: regcmp help Theoretically speaking, this would probably only work with a two-line string, correct? If so, is there a way to do it generically, i.e. where you don't know how many newlines may be in the string nor on which line the desired match may exist, similar to //s in Perl? Justin -----Original Message----- From: help-cfengine-boun...@cfengine.org [mailto:help-cfengine-boun...@cfengine.org] On Behalf Of nwat...@symcor.com Sent: Wednesday, February 17, 2010 1:41 PM To: Mark Burgess Cc: Lebel, Marco; help-cfengine@cfengine.org Subject: Re: regcmp help Mark Burgess <mark.burg...@iu.hio.no> wrote on 2010-02-17 15:37:36: > > .* only matches up to the newline, so you'll have to say > > .*REGEX.*\n.* That works. It's a bit painful compared with m// so I still wish for that :) Still thanks for the clarification and your patience with my stubbornness. Sincerely, -- Neil Watson 416-673-3465 This electronic communication and any attachments may contain confidential and proprietary information of DigitalGlobe, Inc. If you are not the intended recipient, or an agent or employee responsible for delivering this communication to the intended recipient, or if you have received this communication in error, please do not print, copy, retransmit, disseminate or otherwise use the information. Please indicate to the sender that you have received this communication in error, and delete the copy you received. DigitalGlobe reserves the right to monitor any electronic communication sent or received by its employees, agents or representatives. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine On Wed, Feb 17, 2010 at 3:01 PM, Justin Lloyd <jll...@digitalglobe.com> wrote: > Theoretically speaking, this would probably only work with a two-line string, > correct? If so, is there a way to do it generically, i.e. where you don't > know how many newlines may be in the string nor on which line the desired > match may exist, similar to //s in Perl? > > Justin > > -----Original Message----- > From: help-cfengine-boun...@cfengine.org > [mailto:help-cfengine-boun...@cfengine.org] On Behalf Of nwat...@symcor.com > Sent: Wednesday, February 17, 2010 1:41 PM > To: Mark Burgess > Cc: Lebel, Marco; help-cfengine@cfengine.org > Subject: Re: regcmp help > > Mark Burgess <mark.burg...@iu.hio.no> wrote on 2010-02-17 15:37:36: > >> >> .* only matches up to the newline, so you'll have to say >> >> .*REGEX.*\n.* > > That works. It's a bit painful compared with m// so I still wish for that > :) Still thanks for the clarification and your patience with my > stubbornness. > > > Sincerely, > -- > Neil Watson > 416-673-3465 > > > This electronic communication and any attachments may contain confidential > and proprietary > information of DigitalGlobe, Inc. If you are not the intended recipient, or > an agent or employee > responsible for delivering this communication to the intended recipient, or > if you have received > this communication in error, please do not print, copy, retransmit, > disseminate or > otherwise use the information. Please indicate to the sender that you have > received this > communication in error, and delete the copy you received. DigitalGlobe > reserves the > right to monitor any electronic communication sent or received by its > employees, agents > or representatives. > > _______________________________________________ > 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