18.02.2019, 07:25
(
Last edited by Calisthenics; 18/02/2019 at 08:21 AM.
)
Quote:
Plugin works great
However how does one replace text with nothing Code:
new Regex:r = Regex_New("Test "); Regex_Replace("My Test Text", r, "", str); Code:
[Pawn.Regex] Plugin::n_regex_replace: invalid str or fmt Normally I would open up the plugin source and sus it out myself, however I am out of town for a while and only have my craptop |
pawn Code:
main()
{
new Regex: r = Regex_New("^(.+?)?Test\\s(.+?)?$");
if (r)
{
new RegexMatch: m,
group_1[128], group_2[128],
group_1_length, group_2_length;
if (Regex_Match("My Test Text", r, m))
{
Match_GetGroup(m, 1, group_1, group_1_length);
Match_GetGroup(m, 2, group_2, group_2_length);
Match_Free(m);
strcat(group_1, group_2);
print(group_1);
}
Regex_Delete(r);
}
}
pawn Code:
main()
{
new Regex:r = Regex_New("Test ");
if (r)
{
new str[128];
Regex_Replace("My Test Text", r, "\1", str);
Regex_Delete(r);
strreplace(str, "\1", "");
print(str);
}
}
// `strreplace` function from Slice's strlib