LogoLogo
About
  • Home
  • Guides
  • BDK
  • REST API
  • Release Notes
  • Text
    • Overview
  • Boolean Checks
    • Check Text Contents
    • Check Text End
    • Check Text Start
    • Check Regex Match
  • Conversions
    • Convert Character to Number
    • Convert Number to Character
    • Convert Text Date to ISO Format
    • Convert Text to HTML
    • Convert Text to Number
    • Convert Text to Lowercase
    • Convert Text to Titlecase
    • Convert Text to Uppercase
  • Combine Texts
  • Extract Elements from Text
  • Extract Markdown Headings
  • Get Text Length
  • Removal
    • Remove Text Using Regex
    • Remove Text Using Substrings
  • Replacement
  • Splitting
Powered by GitBook
On this page
  • Overview
  • Syntax
  • Data
  • Parameters
  • Examples
  • 1. No removal strategy specified
  • 2. Removing the first occurrence
  • 3. Removing the last occurrence

Was this helpful?

Export as PDF
  1. Removal

Remove Text Using Regex

Removes occurrences of a specified regular expression from a text.

Overview

This operation lets you clean a text by removing all or specific occurrences of a regular expression pattern. You can optionally define the strategy to either remove the first occurrence, the last occurrence, or all occurrences of the matched pattern in the text.

Syntax

This operation supports both of the following syntaxes:

Option 1

This syntax defines the text as data.

the text is "{input}"
the regular expression is "{regex}"
remove the regular expression from the text
	the remove strategy is "{strategy}"

Option 2

the regular expression is "{regex}"
remove the regular expression from "{input}"
	the remove strategy is "{strategy}"

Note: Specifying a remove strategy is optional. By default, all matching occurrences are removed.

Data

The table below lists the names of the data elements in this operation and indicates which can be renamed in the syntax.

Data Name
Can be Renamed

the text

Yes

the regular expression

No

the remove strategy

No

Parameters

Parameters are placeholders for data. Refer to the table below for details on each parameter in this operation. In the syntax, replace parameters with your own values.

input

The text to be cleaned.

The order number is 12345.

Yes

regex

The regular expression pattern to be removed.

[0-9]+

Yes

strategy

The removal strategy. Accepted Values:

  • first - Removes the first occurrence.

  • last - Removes the last occurrence.

  • all - Removes all occurrences. (default)

all

Optional

Examples

1. No removal strategy specified

In this example, no removal strategy is specified, so all matching occurrences are removed by default.

the regular expression is "[0-9]+"
remove the regular expression from "The order number is 12345."
The order number is .

2. Removing the first occurrence

the text is "The order number is 12345, and the reference ID is 67890."
the regular expression is "[0-9]+"
remove the regular expression from the text
  the remove strategy is "first"
The order number is , and the reference ID is 67890.

3. Removing the last occurrence

the text is "The order number is 12345, and the reference ID is 67890."
the regular expression is "[0-9]+"
remove the regular expression from the text
  the remove strategy is "last"
The order number is 12345, and the reference ID is .

Last updated 7 days ago

Was this helpful?