TemplateRegexPosition

Inheritance: java.lang.Object, com.groupdocs.parser.templates.TemplatePosition

public class TemplateRegexPosition extends TemplatePosition

Provides a template field position which uses the regular expression.

The following example shows the situation if the document contains “Invoice Number INV-12345” then template field can be defined in the following way:

// Create a regex template field with "InvoiceNumber" name
 TemplateField templateField = new TemplateField(
     new TemplateRegexPosition("Invoice Number\\s+[A-Z0-9\\-]+"),
     "InvoiceNumber");
 

In this case as a value the entire string is extracted. To extract only a part of the string the regular expression group “value” is used:

// Create a regex template field with "InvoiceNumber" name with "value" group
 TemplateField templateField = new TemplateField(
     new TemplateRegexPosition("Invoice Number\\s+(?[A-Z0-9\\-]+)"),
     "InvoiceNumber");

In this case as a value “INV-3337” string is extracted.

Constructors

Constructor Description
TemplateRegexPosition(String expression) Initializes a new instance of the TemplateRegexPosition class.
TemplateRegexPosition(String expression, boolean matchCase) Initializes a new instance of the TemplateRegexPosition class.

Methods

Method Description
getExpression() Gets the regular expression.
isMatchCase() Gets the value that indicates whether a text case isn’t ignored.

TemplateRegexPosition(String expression)

public TemplateRegexPosition(String expression)

Initializes a new instance of the TemplateRegexPosition class.

Parameters:

Parameter Type Description
expression java.lang.String The regular expression.

TemplateRegexPosition(String expression, boolean matchCase)

public TemplateRegexPosition(String expression, boolean matchCase)

Initializes a new instance of the TemplateRegexPosition class.

Parameters:

Parameter Type Description
expression java.lang.String The regular expression.
matchCase boolean The value that indicates whether a text case isn’t ignored.

getExpression()

public String getExpression()

Gets the regular expression.

Returns: java.lang.String - A string that represents the regular expression.

isMatchCase()

public boolean isMatchCase()

Gets the value that indicates whether a text case isn’t ignored.

Returns: boolean - true if a text case isn’t ignored; otherwise, false .