RegexAnnotator

The RegexAnnotator can be used to perform analysis based on a .NET regular expression.

Configuration

Attribute

Description

Required

Default

annotationTypeId

The type identifier to set on the added annotations.

Yes

N/A

pattern

The .NET regular expression that will be used to perform as the search pattern.

Yes

N/A

ignoreCase

Should upper case and lower case text be treated as equivalent (case insensitivity)?

No

False

Make sure to register the given annotationTypeId as a custom annotation inside the editor.

Capture groups

You can use matched subexpressions or named matched subexpressions to capture the contents of a subexpression. The captured content can be found in the metadata object.

Matched Subexpressions

When using matched subexpressions, a number will be given to each group, starting with 1 and being incremented for each following group.

Expression: ([a-zA-Z0-9_.+-]+)@(fontoxml\.com)

Metadata:

JavaScript

{
    "match": "contact@fontoxml.com",
    "captures": {
        "1": [
            {
                "value": "contact"
            }
        ],
        "2": [
            {
                "value": "fontoxml.com"
            }
        ]
    }
}

Named Matched Subexpressions

When using named matched subexpressions, the given group name is used as a key in the captures object.

Expression: (?<username>[a-zA-Z0-9_.+-]+)@(?<domain>fontoxml\.com)

Metadata:

JavaScript

{
    "match": "contact@fontoxml.com",
    "captures": {
        "username": [
            {
                "value": "contact"
            }
        ],
        "domain": [
            {
                "value": "fontoxml.com"
            }
        ]
    }
}

Produces

Annotation types

The RegexAnnotator produces annotation types as configured in the annotationTypeId attribute.

Metadata

JavaScript

{
	"match": "[The captured substring]",
	"captures": {}
}

Example configuration

The following example shows a RegexAnnotator that annotates fontoxml.com email addresses.

XML

<regexAnnotator annotationTypeId="fontoxml-email" pattern="[a-zA-Z0-9_.+-]+@fontoxml\.com"/>