Quote:
Originally Posted by Calgon
Regular expressions are commonly used to combat these sorts of problems.
pawn Код:
regex_replace(szMessage, "s/{[a-zA-Z\/][^>]*}//g", "", szMessage, sizeof(szMessage));
I imagine the code above should work, I ******d an example for removing HTML tags, as I couldn't remember the wildcard syntax.
|
OH MY GOD! Thank you for linking me to that thread! I never knew it existed. Thanks Calgon!
EDIT: Okay, slight problem! This is my code:
pawn Код:
stock SendAdminMessage(color, string[], administrator[], level = 1)
{
foreach(Player, i)
{
if(pStats[i][EP_ADMINLVL] >= level)
{
SendClientMessage(i, color, string);
}
}
regex_replace(string, "s/{[a-zA-Z\/][^>]*}//g", "", string, sizeof(string)); // line 468
new szQuery[500];
format(szQuery, sizeof(szQuery), "INSERT INTO `adminMessages` (`String`, `Administrator`) VALUES('%s', '%s')", string, administrator);
mysql_query(szQuery, qDefault);
}
... and these are the errors:
Код:
C:\Users\Piccoli\Desktop\SA-MP 0.3d\gamemodes\IGRP.pwn(468) : error 027: invalid character constant
C:\Users\Piccoli\Desktop\SA-MP 0.3d\gamemodes\IGRP.pwn(468) : error 027: invalid character constant
C:\Users\Piccoli\Desktop\SA-MP 0.3d\gamemodes\IGRP.pwn(468) : warning 224: indeterminate array size in "sizeof" expression (symbol "")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
EDIT 2: Okay, it's compiling now with this code, but I don't know about using "strlen" compared to "sizeof"...
pawn Код:
regex_replace(string, \"s/{[a-zA-Z\/][^>]*}//g", "", string, strlen(string));