freemarker.ext.misc
Class Match

java.lang.Object
  extended by freemarker.ext.misc.Match
All Implemented Interfaces:
TemplateMethodModel, TemplateModel, java.io.Serializable

public final class Match
extends java.lang.Object
implements TemplateMethodModel, java.io.Serializable

A method model that implements the Perl 5 match function. This uses the Jakarta ORO library to perform the match.

Usage:
From java:

 TemplateModelRoot root = new SimpleHash();

 root.put( "match", new freemarker.ext.misc.Match() );

 ...
 

From your FM-Classic template:

 The following matches the first two HTML tags:
 <assign text = "<p>This paragraph has <em>tags</em> that will be matched.</p>">
 <assign output = match( "/<([^>]*)>.*<([^>]*)>/", text )>

 Match is: ${output}, first tag is: ${output[1]}, second tag is ${output[2]}.

 ...
 

Since:
1.8.2
Version:
$Id: Match.java 1101 2013-04-01 04:17:32Z run2000 $
Author:
Nicholas Cull
See Also:
Serialized Form

Constructor Summary
Match()
          Construct a new match method.
 
Method Summary
 TemplateModel exec(java.util.List<java.lang.String> arguments)
          Executes a method call.
 boolean isEmpty()
          Is the object empty?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Match

public Match()
Construct a new match method.

Method Detail

isEmpty

public boolean isEmpty()
                throws TemplateModelException
Is the object empty?

Specified by:
isEmpty in interface TemplateModel
Returns:
false to indicate the method is not empty
Throws:
TemplateModelException

exec

public TemplateModel exec(java.util.List<java.lang.String> arguments)
                   throws TemplateModelException
Executes a method call. Arguments are passed as a List of String objects.

Specified by:
exec in interface TemplateMethodModel
Parameters:
arguments - a List of String objects containing the values of the arguments passed to the method.
Returns:
the TemplateModel produced by the method, or null.
Throws:
TemplateModelException