TemplateRegexPosition class
Leave feedback
On this page
Provides a template field position which uses a regular expression.
The position extracts the entire match by default. To extract a specific capture group, include a named group value in the pattern; only the content of that group will be returned as the field value.
The TemplateRegexPosition type exposes the following members:
| Constructor | Description |
|---|---|
| init | Initializes a new TemplateRegexPosition with the specified regular expression. |
| init | Initializes a new TemplateRegexPosition instance. |
| Property | Description |
|---|---|
| expression | The regular expression used to locate values. |
| match_case | The value indicates whether text case is not ignored. |
from groupdocs.parser import Parser
from groupdocs.parser.templates import Template, TemplateField, TemplateRegexPosition
template = Template([
TemplateField(
TemplateRegexPosition(r"Invoice Number\s+(?<value>[A-Z0-9\-]+)"),
"InvoiceNumber",
)
])
with Parser("./invoice.pdf") as parser:
data = parser.parse_by_template(template)
if data:
fields = data.get_fields_by_name("InvoiceNumber")
if fields:
print(f"Invoice number: {fields[0].text}")
- module
groupdocs.parser.templates
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.