bundle common regex in stdlib?

10 views
Skip to first unread message

Nick Anderson

unread,
Jul 30, 2014, 10:47:37 AM7/30/14
to help-c...@googlegroups.com
I am not a regex master, I seem to constantly have to hunt down the same
patterns over and over. Does anyone else think it would be a good
addition to the stdlib to have a bunch of regexes? If yes, would you
like to offer up some candidates?

bundle common regex
{
vars:
"hash_comments_or_blank_lines" string => "\s*#[^\n]*";

}

Shane McEwan

unread,
Jul 30, 2014, 10:57:36 AM7/30/14
to help-c...@googlegroups.com
On 30/07/14 15:47, Nick Anderson wrote:
> I am not a regex master, I seem to constantly have to hunt down the same
> patterns over and over. Does anyone else think it would be a good
> addition to the stdlib to have a bunch of regexes? If yes, would you
> like to offer up some candidates?

I can't say that I've ever found the need to use regexes in CFEngine.
That doesn't mean to say that a standard library of them might not come
in handy.

The logstash grok pattern file has many useful regexes for matching
everyday things:
https://github.com/elasticsearch/logstash/blob/master/patterns/grok-patterns

Shane.


Marco Marongiu

unread,
Jul 30, 2014, 11:10:46 AM7/30/14
to help-c...@googlegroups.com
On 07/30/2014 04:47 PM, Nick Anderson wrote:
> would you
> like to offer up some candidates?

You asked: all of these!

http://search.cpan.org/~abigail/Regexp-Common-2013031301/lib/Regexp/Common.pm

:-)

-- bronto

Ted Zlatanov

unread,
Jul 30, 2014, 11:36:46 AM7/30/14
to help-c...@googlegroups.com
On Wed, 30 Jul 2014 17:10:42 +0200 Marco Marongiu <bront...@gmail.com> wrote:

MM> On 07/30/2014 04:47 PM, Nick Anderson wrote:
>> would you like to offer up some candidates?

MM> You asked: all of these!

MM> http://search.cpan.org/~abigail/Regexp-Common-2013031301/lib/Regexp/Common.pm

I think most of these are not useful to CFEngine *users* but rather to
low-level policy authors (e.g. those who maintain the stdlib or other
frameworks). So if it makes sense, add it without trying to make it
user-friendly.

The other issue is that regular expressions often can't be factored out
without harming readability because you end up with a mix of regular
expressions and variable expansions that you have to look up.

Ted

Reply all
Reply to author
Forward
0 new messages