.. _functx_replace-first: ==================== functx:replace-first ==================== Substitui a primeira ocorrência de um padrão Descrição ~~~~~~~~~ A função functx:replace-first substitui, dentro de $arg, o primeiro trecho que casa com $pattern por $replacement. Se nenhum trecho casar com o padrão, nada é substituído. .. list-table:: :widths: 40 60 :header-rows: 1 * - **Parâmetros** - **Descrição** * - arg:string() - a string inteira a alterar * - pattern:string() - o padrão de caracteres a substituir * - replacement:string() - a string de substituição Exemplos ~~~~~~~~ .. list-table:: :widths: 50 50 :header-rows: 1 * - **XPath** - **Resultado** * - functx:replace-first('abcabcabc', 'ab', 'x') - xcabcabc * - functx:replace-first('elementary', 'e.\*e', 'x') - xntary * - functx:replace-first('elementary', 'e.\*?e', 'x') - xmentary * - functx:replace-first('9999-9999', '\\d+', 'X') - X-9999 * - functx:replace-first('9999-9999', '\\d{3}', 'X') - X9-9999 Veja também ~~~~~~~~~~~ .. toctree:: :titlesonly: :glob: * :ref:`functx_replace-beginning`. * :ref:`replace`.