Re: [Puppet Users] property file provider

Stefan Schulte
Tue, 23 Aug 2011 21:12:15 -0000

On Tue, Aug 23, 2011 at 04:27:30PM -0400, David Kavanagh
wrote:
> I understand regular expressions. been doing them a long time in
> various languages. But, how are the fields determined from this regex?
>
> David
>

You have to put everything you want to capture in parentheses, so

  /^Hello (.*)$/.match(''Hello World'').captures ==
[''World'']

However if you want to just define a block and you don''t
want to capture it you can use (?: and ) instead of ( and ).

I used that in the regex like in

  (?:\s*=\s*(.*?))?

This means there is an optional equal sign with stuff after it as
indicated by the quotation mark after the block marked with the
outer parentheses (?: and ). But I dont want to capture the whole
block so I just capture what is after the equal sign
(the inner parentheses).

Does this answers your question?

-Stefan