regular_expression: uma expressão regular que corresponde a uma parte de X.
replacement: o texto que substitui a parte de correspondência de field_expression.
Retorna
A função REGEXP_REPLACE retorna valores Text.
Observações
REGEXP_REPLACE retorna o texto em que todas as substrings de X que correspondem a regular_expression são substituídas por X.
Use dígitos de escape com barra invertida (\1 a \9) no argumento replacement para inserir um texto correspondente ao grupo entre parênteses no padrão regular_expression. Use \0 para indicar o texto correspondente inteiro.
Para procurar uma barra invertida literal na sua expressão regular, insira uma segunda barra invertida antes da barra invertida literal. Exemplo:
REGEXP_REPLACE('abc', 'b(.)', 'X\\1');
retorna aXc.
Também é possível usar strings brutas para remover uma camada de escape. Exemplo:
REGEXP_REPLACE('abc', 'b(.)', r'X\1');
A função REGEXP_REPLACE substitui apenas as correspondências não sobrepostas. Por exemplo, substituir ana em banana resulta em apenas uma substituição, não duas.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-25 UTC."],[],[],null,["# REGEXP_REPLACE\n\nReplaces text within the target value.\n\nSample usage\n------------\n\n`REGEXP_REPLACE(Campaign, '(Sale):(Summer)', '\\\\2 \\\\1')`\n\nSyntax\n------\n\n`REGEXP_REPLACE( `\u003cvar translate=\"no\"\u003eX\u003c/var\u003e`, `\u003cvar translate=\"no\"\u003eregular_expression\u003c/var\u003e`, `\u003cvar translate=\"no\"\u003ereplacement\u003c/var\u003e` )`\n\n### Parameters\n\n- \u003cvar translate=\"no\"\u003eX\u003c/var\u003e - a field or expression that includes a field.\n- \u003cvar translate=\"no\"\u003eregular_expression\u003c/var\u003e - a regular expression that matches a portion of \u003cvar translate=\"no\"\u003eX\u003c/var\u003e.\n- \u003cvar translate=\"no\"\u003ereplacement\u003c/var\u003e - the text with which to replace the matched portion of `field_expression`.\\`\n\n### Returns\n\nThe `REGEXP_REPLACE` function returns **Text** values.\n\n### Notes\n\n`REGEXP_REPLACE` returns text where all substrings of \u003cvar translate=\"no\"\u003eX\u003c/var\u003e that match \u003cvar translate=\"no\"\u003eregular_expression\u003c/var\u003e are replaced with *X*.\n\nYou can use backslashed-escaped digits (\\\\1 to \\\\9) within the \u003cvar translate=\"no\"\u003ereplacement\u003c/var\u003e argument to insert text matching the corresponding parenthesized group in the \u003cvar translate=\"no\"\u003eregular_expression\u003c/var\u003e pattern. Use \\\\0 to refer to the entire matching text.\n\nTo search for a literal backslash in your regular expression, you must escape the literal backslash with a second backslash. For example:\n\n`REGEXP_REPLACE('abc', 'b(.)', 'X\\\\1');`\n\nreturns `aXc`.\n\nYou can also use [raw strings](/bigquery/docs/reference/standard-sql/lexical#string_and_bytes_literals) to remove one layer of escaping. For example:\n\n`REGEXP_REPLACE('abc', 'b(.)', r'X\\1');`\n\nThe `REGEXP_REPLACE` function only replaces non-overlapping matches. For example, replacing `ana` within `banana` results in only one replacement, not two.\n\nExamples\n--------\n\nRelated resources\n-----------------\n\n- [Regular expressions in Looker Studio](/looker/docs/studio/regular-expressions-in-looker-studio)\n- [About calculated fields](/looker/docs/studio/about-calculated-fields)\n- [Looker Studio function list](/looker/docs/studio/function-list)"]]