Match () with regex () ()

Revision as of 18:25, 8 June 2024 by Ninja 6734 (talk | contribs) (New comments)

Information

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

match with regex block
match with regex block

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 ? (please add what this input box does)

Examples

Foo bar example

match with regex: first example
Example 1

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 with regex: second example
Example 2

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

Regular expression rule syntax

The rules of regular expressions have their own syntax which you can all look up on this website.

The examples will appear as: [to be matched string] [rule] [third input] -> [result]

Syntax Table
meta characters Description Example
. This is the syntax for any character ["gray grey griy gary"] ["gr.y"] ["g"] -> ["gray", "grey", "griy"]
() groups a set of characters No actual change to the result, will be needed later on
+ matches the preceding character or group one or more times ["abbbbbba aba aa"] ["ab+a"] ["g"] -> ["abbbbbba","aba"]
? matches the preceding character or group zero or one times ["aba aa abba abbbba"] ["a?ba"] ["g"] -> ["aba","aa"]
* matches the preceding character or group any amount of times ["aba aa abbbbbbbba abbbbbbbbbbbbba"] ["ab*a"] ["g"] -> ["aba", "aa", "abbbbbbbba", "abbbbbbbbbbbbba"]
{M,N} matches the preceding character or group

a minimum of M to a naximum of N times

["aba abbba abbbbba abbbbbbbbbbba"] ["ab{3,5}a"] ["g"] -> ["abbba","abbbbba"]
{,N} matches the preceding character or group a maximum of N times ["aba abbba abbbbba abbbbbbbbbbba"] ["ab{,5}a"] ["g"] -> ["aba", "abbba", "abbbbba"]
{M,} matches the preceding character or group a minimum of M times ["aba abbba abbbbba abbbbbbbbbbba"] ["ab{3,}a"] ["g"] -> ["abbba", "abbbbba", "abbbbbbbbbbba"]
{N} matches the preceding character or group exactly N times ["aba abbba abbbbba abbbbbbbbbbba"] ["ab{3}a"] ["g"] -> ["abbba"]
[...] syntax for any characters or group within the rectangular parenthesis ["Hello Hallo Hmllo Hkllo"] ["H[ea]llo"] ["g"] -> ["Hello","Hallo"].

This can also used like this: ["Hello Hallo Hmllo Hkllo"] ["H[a-k]llo"] ["g] -> ["Hello","Hallo", "Hkllo"].

which acts as every letter in the alphabet from a to k

| seperating possible character or groups ["gray grey griy gary"] ["(gray|grey|griy)"] ["g"] -> ["gray", "grey", "griy"]
\w syntax for all Alphanumericals (a-z A-Z 0-9 and _) ["This is a_text90§!"] ["\w"] ["g"] -> ["T","h","i","s","i","s","a","_","t","e","x","t","9","0"]
\W syntax for all non-Alphanumericals not (a-z A-Z 0-9 and _) ["This is a_text90§!"] ["\W"] ["g"] -> ["§","!"]

Comments

if someone knows what the third input is for please add it here
-- Ninja 6734 (talk) 18:25, 8 June 2024 (UTC)