Regex Replace

BlockRegex

Replace all matches of a regular expression in a string.

Inputs

RegexRequired

Regular expression to search with.

Example: (foo)

TextRequired

Text to run the regex against.

Example: foo bar baz

Replacement

Text to replace matches with.

Example: qux

Outputs

Replaced String

String after all replacements.

Example: qux bar baz

Build a bot using blocks like Regex Replace

Use this block in our visual flow editor. Bots are hosted 24/7 for free on inventor.bot.

Advanced Documentation

This documentation can be useful when using code mode. View as Markdown

ID: regex_replace

Inputs

FieldInventScript nameValue
Regexregexe.g. "(foo)"
Texttexte.g. "foo bar baz"
Replacementreplacemente.g. "qux"

Outputs

FieldInventScript nameValue
Replaced Stringreplaced_stringe.g. "qux bar baz"

Example InventScript

regexReplace := regex_replace(Args{regex: "(foo)", text: "foo bar baz"})
send_text_message(Args{
	channel_id:      trigger.channel_id,
	message_content: "Replaced String: " + regexReplace.replaced_string,
})

More regex blocks