About this
https://sm.alliedmods.net/new-api/re...ex/MatchOffset
- I'm not sure do I use it right.
Should this return offset of match in string ?
It now return offset of end of match in string.
Below example match STEAM_ id pattern.
output
Code:
sm plugins reload test
"<STEAM_0:1:23456> Baca bacardi jump over brown fox STEAM_7:8:9012345678 rolling down the hill, hit his head on rock"
numofmatch 2
> Baca bacardi jump over brown fox STEAM_7:8:9012345678 rolling down the hill, hit his head on rock
matchoffset 16
rolling down the hill, hit his head on rock
matchoffset 71
[SM] Plugin test.smx reloaded successfully.
PHP Code:
#include <regex>
Regex rextest;
char loremipsum[] = {
"<STEAM_0:1:23456> Baca bacardi jump over brown fox \
STEAM_7:8:9012345678 rolling down the hill, hit his head on rock"
}
public void OnPluginStart()
{
rextest = new Regex("(STEAM_\\d:\\d:\\d+)");
int numofmatch = rextest.MatchAll(loremipsum);
int matchoffset;
if(numofmatch > 0)
{
PrintToServer("\"%s\"\n", loremipsum);
PrintToServer("numofmatch %i", numofmatch);
for(int a = 1; a < numofmatch; a++)
{
for(int b = 0; b < rextest.CaptureCount(a); b++)
{
matchoffset = rextest.MatchOffset(b);
PrintToServer("%s", loremipsum[matchoffset]);
PrintToServer("matchoffset %i\n", matchoffset);
}
}
}
}