--- title: "cut-until-match()" slug: "string-cut-until-match" updated: 2026-08-17T06:07:43Z published: 2026-08-17T06:07:43Z canonical: "docs.lobstersoftware.com/string-cut-until-match" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # cut-until-match() This function removes characters from text **a** (from left or right) until the regular expression **b** matches. The function returns the first trimmed text that matches the regular expression. If the regular expression never matches, an empty string is returned. ## Parameters | Parameter | Description | | --- | --- | | a | Text. | | b | Regular expression. | | c | (optional) "true" if the text should be trimmed from the right side. "false" if the text should be trimmed from the left side. Default: "false". | ## Examples | Parameter a | Parameter b | Parameter c | Result | | --- | --- | --- | --- | | 000978456008918765 | ^[1-9].* | | 978456008918765 | | 000978456008918765 | ^[1-9].* | false | 978456008918765 | | 000978456008918765 | ^[1-9].* | true | | | hello, world?!#*** | .*\?$ | true | hello, world? |