Match () with regex () ()

From PenguinMod Wiki
Revision as of 14:18, 6 July 2024 by Steve0Greatness (talk | contribs) (Go up a heading)
Jump to navigation Jump to search
Match () with regex () ()
...
[[File:
(match [foo bar] with regex [foo] [g] :: operators)
|200px]]
Caption
Block Type Reporter Block
Category / Extension Operators
Status Who tf uses status

Information

The match regex block is a reporter block that matches a string with a regular expression, a regex.

Use

This block searches for every instance of the selected rule. The rule can be inserted into the second input box. The third input box acts as a flag (more info later on)

Examples

Foo bar example

(match [foo bar] with regex [foo] [g] :: operators) // ["foo"]

In this example inputs of the block it searches for the string "foo" in the string "foo bar" which will result in the array ["foo"] since there is only one foo in the string.

Fruit example

(match [banana orange apple banana banana pear apple] with regex [banana] [g] :: operators) // ["banana","banana","banana"]

For this example the block searches for every occurance of the word "banana" which results in the array ["banana","banana","banana"].

See Also