.. _functx_substring-before-last-match: ================================== functx:substring-before-last-match ================================== The substring after the first text that matches a regex Description ~~~~~~~~~~~ The functx:substring-before-last-match function returns the part of $arg that appears before the last match of $regex. If $arg does not match $regex, the entire $arg is returned. If $arg is the empty sequence, the empty sequence is returned. .. list-table:: :widths: 40 60 :header-rows: 1 * - **Parameters** - **Description** * - arg:string() - the string to substring * - regex:string() - the regular expression Examples ~~~~~~~~ .. list-table:: :widths: 50 50 :header-rows: 1 * - **XPath** - **Results** * - functx:substring-before-last-match('abc-def-ghi', '[ce]') - abc-d * - functx:substring-before-last-match('abcd-abcd', 'ab?') - abcd- * - functx:substring-before-last-match('abcd-abcd', 'x') - abcd-abcd See Also ~~~~~~~~ .. toctree:: :titlesonly: :glob: * :ref:`substring-before`. * :ref:`functx_substring-before-match`. * :ref:`functx_substring-after-match`. * :ref:`functx_substring-after-last-match`.