Re: Find number of matches using Match
Ronald J Kimball <rkimball-jkI2qz8QNLsmlAP/[email protected]> Tue, 22 May 2012 15:09:09 -0400
| Newsgroups | gmane.comp.lang.perl.modules.template-toolkit |
|---|---|
| Message-ID | <CAEnkCGTx9mbRd7w0PuZBDx1OSKnXL=-zDSBxb6_5BV9QNF8Bmw@mail.gmail.com> |
On Tue, May 22, 2012 at 2:03 PM, Summer <crazysummer2004-/[email protected]> wrote: > Initially I did try this and it didn' work. After trying out the following > example: > > [% text = 'no, i do not believe we could not go forward to the sea. I > know. no'; %] > > So, to get the count: > [% text.match('no', 1).size %] > > That should match 5x, yet it shows 1 when I do .size > It works for me. $ cat tmp.tt2 [% text = 'no, i do not believe we could not go forward to the sea. I know. no'; -%] [% text.match('no', 1).size %] $ tpage tmp.tt2 5 What version of Template::Toolkit are you using? I have 2.22. Ronald _______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates