Regex Find Matches Iterator

LoopRegex

Iterate over matches of a regular expression in a string.

  • Loop block: the blocks placed inside it run once for each item, and can use the current item's outputs.

Inputs

RegexRequired

Regular expression to search with.

Example: (\\w+)

TextRequired

Text to search through.

Example: foo bar baz

Loop Body

Blocks to run for each match.

Holds blocks

Outputs

Iteration Number

Current iteration (1-based).

Example: 1

Total Iterations

Total number of matches found.

Example: 5

Match

Matched text.

Example: foo

Build a bot using blocks like Regex Find Matches Iterator

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_find_iterator
  • Loop block: write for item := range regex_find_iterator(Args{...}) { ... } and read the current item's outputs from item. See loops.

Inputs

FieldInventScript nameValue
Regexregexe.g. "(\\\\w+)"
Texttexte.g. "foo bar baz"
Loop Bodybodyblocks: func() { ... }

Outputs

FieldInventScript nameValue
Iteration Numberiteration_numbere.g. "1"
Total Iterationstotal_iterationse.g. "5"
Matchmatche.g. "foo"

Example InventScript

for match := range regex_find_iterator(Args{regex: "(\\\\w+)", text: "foo bar baz"}) {
	send_text_message(Args{channel_id: trigger.channel_id, message_content: "Match: " + match.match})
}

More regex blocks