On Mon, May 21, 2012 at 9:44 PM, Summer <crazysummer2...@yahoo.com> wrote:
> Hey, > > I am using the "match" method and I am looking for a regex in a string. > For the sake of argument, lets say we are looking for "no" in the following. > > testString =""no, i do not believe we could not go forward to the sea. I > know. no; > > so, > valHolder = testString.match("(?i:no)"); > > valHolder.size -> always gives me 1. Yet I am expecting 4 matches. > > Is there a way I can know the count of the matches? > > http://template-toolkit.org/docs/manual/VMethods.html#method_match To perform a global search to match the pattern as many times as it appears in the source string, provide a true value for the "global" argument following the pattern. [% text = 'bandanna'; text.match('an+', 1).join(', ) # an, ann %] So, to get the count: [% text.match('no', 1).size %] Ronald
_______________________________________________ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates