Posting to the list... Please keep it there. Thanks!
On Wed, 27 May 2015 10:41:29 +0200 Jochen Schnuerle <j...@schnuerle.com> wrote: > Chad, > > this works fine: > > <% IF esxi.match("\\b${esxiver}\\b") %> > > > but this: > > <% IF esxi.match('\b' _ ${esxiver} _ '\b') %> > > > I could not manage to work ... Oops! My mistake. When you're not interpolating (inside a string), you don't use the dollar sign and braces around the variable. It should have been this: <% IF esxi.match('\b' _ esxiver _ '\b') %> Anyway, I'm glad at least one of my solutions worked. :-) Oh, I just thought of one more thing... It probably doesn't matter in your case, because your version strings don't include dots or other metacharacters. However, if they did, you'd want to escape them, because, for instance, in a regular expression the dot (.) stands for "any character." The simplest approach to this would be the escape sequences \Q and \E in the regexp: <% IF esxi.match('\b\Q' _ esxiver _ '\E\b') %> You can read more about it in the quotemeta section in perldoc perlfunc, or here: http://perldoc.perl.org/functions/quotemeta.html > > Chad Wallace <mailto:cwall...@lodgingcompany.com> > > 26. Mai 2015 20:06 > > On Tue, 26 May 2015 16:53:19 +0200 > > Jochen Schnuerle<j...@schnuerle.com> wrote: > > > >> I have following code (i use dancer - so<% is [%): > >> > >> <% esxiver = "51u2" %> > > [...] > >> I try use the re in the match string direct: > >> > >> <% IF esxi.match('\b${esxiver}\b') %> > >> > >> Maybe I misunterstand the match method. > >> > >> Can anyone help me, please ? > > > > Perhaps it would interpolate if you use double quotes: > > > > <% IF esxi.match("\b${esxiver}\b") %> > > > > ...but you may have to escape the backslashes by doubling them: > > > > <% IF esxi.match("\\b${esxiver}\\b") %> > > > > Or else just concatenate it: > > > > <% IF esxi.match('\b' _ ${esxiver} _ '\b') %> > > > > -- C. Chad Wallace, B.Sc. The Lodging Company http://www.lodgingcompany.com/ OpenPGP Public Key ID: 0x262208A0 _______________________________________________ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates