regex_match
Builtin index · Collections & strings
result = regex_match(s, pattern)
Input: s, pattern · Output: result
What it is
s and pattern are Strs (pattern a regular expression).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = regex_match(s, pattern) | s Strnot documented yetpattern Strnot documented yet | result bool or string | Returns a bool: whether the pattern occurs anywhere in s. Anchor it with ^/$ to test the whole string. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
print(regex_match("[0-9]+", "abc123")) # false
print(regex_match("[0-9]+", "[0-9]+")) # true <- a smoke test passes
output
false true
from agent-guide
print(regex_match("abc123", "[0-9]+")) # true
print(regex_count("a1b22c333", "[0-9]+")) # 3
output
true 3
from agent-guide
s = "sensor_1: 12.4, sensor_2: 9.8, sensor_3: 15.0"
print(regex_match(s, "sensor_[0-9]+")) # true
print(regex_find(s, "[0-9]+\.[0-9]+")) # "12.4"
print(regex_split(s, ", *")) # 3-piece split on each comma
print(regex_count(s, "sensor_")) # 3
output
true
12.4
("sensor_1: 12.4", "sensor_2: 9.8", "sensor_3: 15.0")
3from collections-strings