Regex remove
Function: Regex remove
This action helps you clean up or modify text by finding and removing specific patterns. You provide the original text and a special pattern (called a "regular expression" or "regex"), and the action will remove all parts of the text that match that pattern. This is useful for tasks like stripping out unwanted characters, sensitive information, or formatting.
Input
- Text: The original piece of text you want to modify. (Type: Text, Required)
- Regex: The pattern you want to find and remove from the text. This pattern uses a special language called "regular expressions" to describe what to look for. (Type: Text, Required)
- Result Variable Name: The name you want to give to the variable that will hold the modified text. If you don't specify one, it will be named "RESULT" by default. (Type: Text, Required)
Output
The action will produce a new variable (named as specified in "Result Variable Name", or "RESULT" by default) containing the original text with all occurrences of the specified pattern removed.
Execution Flow
Real-Life Examples
Example 1: Cleaning up extra spaces
Imagine you have text copied from various sources, and it often contains multiple spaces between words or at the beginning/end of sentences. You want to normalize it to have only single spaces.
- Inputs:
- Text: " Hello World! How are you? "
- Regex: "\s+" (This pattern matches one or more whitespace characters)
- Result Variable Name: "CleanedSentence"
- Result: A new variable named
CleanedSentencewill be created, containing the value "HelloWorld!Howareyou?".
Example 2: Removing sensitive phone numbers
You have a customer message that might contain phone numbers, and you need to remove them before storing the message in a public log.
- Inputs:
- Text: "Please call me at 123-456-7890 or my office at (987) 654-3210. My mobile is 555.123.4567."
- Regex: "\(?\d{3}\)?[-\s.]?\d{3}[-\s.]?\d{4}" (This pattern matches common phone number formats like
XXX-XXX-XXXX,\(XXX\) XXX-XXXX,XXX.XXX.XXXX) - Result Variable Name: "RedactedMessage"
- Result: A new variable named
RedactedMessagewill be created, containing the value "Please call me at or my office at . My mobile is ."
Example 3: Stripping HTML tags from content
You've received content that includes HTML formatting, but you only need the plain text for a notification or a summary.
- Inputs:
- Text: "<h1>Welcome</h1><p>This is <b>important</b> information.</p><ul><li>Item 1</li><li>Item 2</li></ul>"
- Regex: "<[^>]+>" (This pattern matches any text enclosed within angle brackets, like HTML tags)
- Result Variable Name: "PlainTextContent"
- Result: A new variable named
PlainTextContentwill be created, containing the value "WelcomeThis is important information.Item 1Item 2".