public class TemplateRegexPosition extends TemplatePosition
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+(?<value>[A-Z0-9\\-]+)"),
"InvoiceNumber");
In this case as a value "INV-3337" string is extracted.
| Constructor and 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. |
| Modifier and Type | Method and Description |
|---|---|
String |
getExpression()
Gets the regular expression.
|
boolean |
isMatchCase()
Gets the value that indicates whether a text case isn't ignored.
|
TemplatePosition |
scale(double factor)
Creates a copy of the current position with all coordinates scaled by the given factor.
|
public TemplateRegexPosition(String expression)
TemplateRegexPosition class.expression - The regular expression.public TemplateRegexPosition(String expression, boolean matchCase)
TemplateRegexPosition class.expression - The regular expression.matchCase - The value that indicates whether a text case isn't ignored.public String getExpression()
public boolean isMatchCase()
true if a text case isn't ignored; otherwise, false.public TemplatePosition scale(double factor)
TemplatePositionscale in class TemplatePositionfactor - The scaling factor.TemplatePosition with scaled coordinates.Copyright © 2026. All rights reserved.