Skip to main content
Version: v6.0.0

Regex Translation

motivation

At the time of writing, there is no built-in Logic App functionality available to run regular expression replacements without using inline code. The Invictus Regex Translation Framework component was created to fill this missing gap, by providing a HTTP-endpoint to run regular expression replacements. Available translations are stored in an Azure Table Storage.

Regex translate user content

The Regex Translation component has a single endpoint available: /api/RegexTranslation. Given an user content and matched stored (Azure Table Storage) regex translation, the endpoint responds with the translated content.

The following request body properties must be supplied:

JSON propertyRequiredDescription
ContentyesUser content that should translated.
MatchKeyyesSet of 'keys' that translates to Azure Table Storage partition keys.
Full request example
// POST /api/RegexTranslation
{
"Content": "The provided host name 'website.com' could not be resolved",
"MatchKey": ["OrderService", "InvoiceService"]
}
Full response example
// Found stored translation:
// 200 OK <- /api/RegexTranslation
{
"Content": "System could not reach endpoint 'website.com' as it is not available, please contact John to follow-up.",
"IsTranslated": true,
"RowKey": "2f71ec69-1fff-4b80-9ae1-947a58e4a039"
}

// Did not found stored translation:
// 200 OK <- /api/RegexTranslation
{
"Content": "The provided host name 'website.com' could not be resolved",
"IsTranslated": false,
"RowKey": ""
}

Stored regex translations

Regex translations should be stored in an Azure Table Storage table called RegexTranslator (created automatically by Invictus). Each stored entity should have following custom properties:

Custom entity property nameDescription
MatchPatternThe regular expression to match the incoming user Content. It uses named groups to cut certain information from the content.
OutputPatternThe outgoing text, containing possible {group-name} occurrences to paste the subtracted information.
Full translation example
Entity property nameValue
RowKey2f71ec69-1fff-4b80-9ae1-947a58e4a039
PartitionKeyOrderService
MatchPattern"The provided host name '(?<url>[^]*)' could not be resolved."
OutputPattern"System could not reach endpoint '{url}' as it is not available, please contact John to follow-up."

Translation happens with the following:

  • Multiple pastes: the subtracted information from named groups can be pasted more than once.
  • Single match: the user Content can only be matched to a single stored translation - the first match will be picked.
  • No pastes: the OutputPattern does not necessarily have to contain {group-name} occurrences, it can only contain text.