TemplateRegexPosition
Contents
[
Hide
]
TemplateRegexPosition class
Provides a template field position which uses the regular expression.
public sealed class TemplateRegexPosition : TemplatePosition
Constructors
Name | Description |
---|---|
TemplateRegexPosition(string) | Initializes a new instance of the TemplateRegexPosition class. |
TemplateRegexPosition(string, bool) | Initializes a new instance of the TemplateRegexPosition class. |
Properties
Name | Description |
---|---|
Expression { get; } | Gets the regular expression. |
MatchCase { get; } | Gets the value that indicates whether a text case isn’t ignored. |
Examples
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.
See Also
- class TemplatePosition
- namespace GroupDocs.Parser.Templates
- assembly GroupDocs.Parser