.. _functx_replace-first: ==================== functx:replace-first ==================== Replaces the first match of a pattern Description ~~~~~~~~~~~ The functx:replace-first function replaces, within $arg, the first area that matches $pattern) with $replacement. If no area matches the pattern, no replacement is made. .. list-table:: :widths: 40 60 :header-rows: 1 * - **Parameters** - **Description** * - arg:string() - the entire string to change * - pattern:string() - the pattern of characters to replace * - replacement:string() - the replacement string Examples ~~~~~~~~ .. list-table:: :widths: 50 50 :header-rows: 1 * - **XPath** - **Results** * - 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 See Also ~~~~~~~~ .. toctree:: :titlesonly: :glob: * :ref:`functx_replace-beginning`. * :ref:`replace`.