Communications Mining
Mais recente
falso
Guia do usuário do Communications Mining
Last updated 2 de jul de 2024

Building custom regex general fields

Permissões necessárias: "Modificar conjuntos de dados".

What are Custom Regex General Fields?

A Custom Regex General Field can be used to extract and format spans of text that have a known repetitive structure, such as IDs or reference numbers.

This is a useful option for simple, structured general fields with little variation, whereas for those with significant variation and where context has a big influence on predictions, a machine-learning based general field would be the right choice. Combinations of the two can be used in any dataset within Communications Mining.

A broader Regex (i.e. set of rules to define the general field) can also be used as the base of a custom general field. This combines the rules with contextual, machine learning based refinement through training within Communications Mining to create sophisticated custom general fields. This provides the most optimal performance as well as the necessary restrictions on values extracted for automation.

Modelo de Regex personalizado

A Custom Regex General Field is made up of one or more Custom Regex Templates. Each template expresses one way to extract (and format) the general field.

Combined together, these templates offer a flexible and powerful way to cover multiple representations of the same general field type.

Um modelo é composto de duas partes:

  1. The regex (regular expression), which describes the constraints that need to be met by a span of text to be extracted as a general field
  2. A formatação, que expressa como normalizar a string extraída em um formato mais padrão

Por exemplo, se os IDs dos seus clientes podem ser a palavra “ID” seguida de 7 dígitos ou uma string alfanumérica de 9 caracteres, veja como seus dois modelos ficarão:



Validação de digitação avançada

Ao digitar na caixa de texto para Regex ou Formatação, a interface fornecerá um feedback imediato sobre a validade da entrada. Por exemplo, o Regex de entrada inválido ID\d{} mostrará:

Visualização da extração

The Custom Regex Template can be tested on text to ensure that it behaves as expected. Any general field that would be extracted with the Template will be shown in a list, with its value, as well as the position of the start and end characters.

Por exemplo, se o Regex for \d{4} e a formatação ID-{$}, a seguinte string de teste mostrará uma extração:


Regex

The regex is the pattern used to extract general fields in the text. See here for the syntax documentation.

Os grupos de captura nomeados podem ser usados para identificar uma seção específica da string extraída para formatação subsequente. Os nomes dos grupos de captura devem ser exclusivos em todos os modelos e devem conter apenas letras minúsculas ou dígitos.

Formatting

Formatting can be provided to post-process the extracted general field.

Por padrão, nenhuma formatação é aplicada e a string retornada pela plataforma será a string extraída pelo regex. No entanto, se necessário, transformações mais complexas podem ser definidas, usando as seguintes regras.

Variáveis

Qualquer grupo de captura nomeado definido no regex estará disponível para uso na lógica de formatação como uma variável, prefixada com o símbolo $ . Observe que o símbolo $ , por si só, representa a correspondência completa do regex.
Então, as variáveis podem ser usadas na formatação de strings para inserir o período extraído correspondente no valor retornado pela plataforma; o nome da variável precisa estar envolvido por { e } chaves.
Por exemplo, se quisermos extrair sete dígitos como um ID e retornar esses sete dígitos prefixados com ID- , então o regex e a formatação seriam:


Ou, usando um grupo de captura nomeado:


Later on, if the platform is given the text: My identification number is 1234567, it will return one general field: My identification number is 1234567, it will return one general field: ID-1234567

Operações de string

Strings brutas podem ser usadas, e strings podem ser concatenadas usando o símbolo & .
Regex(?P<id1>\b\d{3}\b)|(?P<id2>\b\d{4}\b)
Formatting{$id1 & "-" & $id2}
TextoO primeiro ID é 123 e o segundo é 4567
General Field returned by the platform123-4567

Funções

Algumas funções também podem ser usadas na formatação para transformar a string extraída. Os nomes das funções e suas assinaturas são inspirados no Excel.

Superior

Converte todos os caracteres no intervalo extraído para letras maiúsculas:

Regex\w{3}
Formatting{upper($)}
Textoabc
General Field returned by the platformABC

Inferior

Converte todos os caracteres no período extraído para minúsculas:

Regex\w{3}
Formatting{lower($)}
TextoAbC
General Field returned by the platformabc

Própria

Para capitalizar o período extraído:

Regex\w+\s\w+
Formatting{proper($)}
TextoGilberto EINSTEIN
General Field returned by the platformAlberto Einteniense

Preencher

Aumenta o período extraído até um determinado tamanho com um determinado caractere.

Argumentos de função:

  1. O texto com os caracteres a serem preenchidos
  2. Tamanho da string preenchida
  3. Caractere a ser usado para preenchimento
Regex\d{2,5}
Formatting{pad($, 5, "0")}
Texto123
General Field returned by the platform00123

Substituir

Substitui caracteres por outros caracteres.

Argumentos de função:

  1. O texto com os caracteres a serem substituídos
  2. Quais caracteres substituir
  3. Como os caracteres antigos devem ser substituídos
Regexab
Formatting{substitute($, "a", "12")}
Textoab
General Field returned by the platform12b

Left

Retorna os primeiros n caracteres do período.

Argumentos de função:

  1. O texto com os caracteres a serem extraídos
  2. O número de caracteres a serem retornados
Regex\w{4}
Formatting{left($, 2)}
TextoABCD
General Field returned by the platformAB

Direita

Retorna os últimos n caracteres do período.

Argumentos de função:

  1. O texto com os caracteres a serem extraídos
  2. O número de caracteres a serem retornados
Regex\w{4}
Formatting{right($, 2)}
TextoABCD
General Field returned by the platformCD

Meio

Retorna n caracteres após a posição especificada do período.

Argumentos de função:

  1. O texto com os caracteres a serem extraídos
  2. A posição do primeiro caractere a retornar
  3. O número de caracteres a serem retornados
Regex\w{5}
Formatting{mid($, 2, 3)}
TextoABCDE
General Field returned by the platformBCD

Was this page helpful?

Obtenha a ajuda que você precisa
Aprendendo RPA - Cursos de automação
Fórum da comunidade da Uipath
Logotipo branco da Uipath
Confiança e segurança
© 2005-2024 UiPath. All rights reserved.