squirrel/samples/regex.nut
mingodad 85e82ea746 Remove set of unused variables.
Add a new matching rule \m that behaves similar to lua %b, it matches a balanced open and close characters ex:
\m() <- will match a balanced pair of ( and )
\m{} <- will match a balanced pair of { and }
See lua %b for more info.
Also include a nut file as example.
2016-01-18 20:32:38 +00:00

11 lines
352 B
Plaintext

local ex = regexp("[a-zA-Z]+");
local string = "123 Test; strlen(str);";
local res = ex.search(string);
print(string.slice(res.begin,res.end)); //prints "Test"
print("\n");
ex = regexp(@"\m()");
string = "123 Test; doSomething(str, getTemp(), (a+(b/c)));";
res = ex.search(string);
print(string.slice(res.begin,res.end)); //prints "(...)"
print("\n");