[GnomeMeeting-devel-list] Do you like smileys?
- From: PUYDT Julien <julien puydt laposte net>
- To: GnomeMeeting Devel Liste <gnomemeeting-devel-list gnome org>
- Subject: [GnomeMeeting-devel-list] Do you like smileys?
- Date: Tue, 30 Sep 2003 21:12:47 +0200
Hi,
the attached program uses a regex, and tests it against all smileys
recognized by gnomemeeting.
This is an awful regex. I would need help to make it better; I see
several ways it could happen:
* decide to remove some smileys, that are unused, and make the regex
longer;
* add smileys, that really should be there, and whose absence makes the
regex longer;
* be smarter than myself, and come up with a wonderfully efficient&good
regex.
Snark
#include <regex.h>
int
main (int argc, char **argv)
{
regex_t regex;
regmatch_t regmatch;
char *regtxt = "(:[-]?(\\)|\\(|o|0|p|P|D|\\||/)|\\}:(\\(|\\))|\\|[-]?(\\(|\\))|:'\\(|:\\[|:-(\\.|\\*|x)|;[-]?\\)|(8|B)[-]?\\)|X(\\(|\\||\\))|\\((\\.|\\|)\\)|x\\*O)";
static char *table_smiley [] =
{
":)",
":(",
":-(",
":0",
":o",
":-0",
":-o",
":-D",
":D",
":-)",
":|",
":-|",
":-/",
":/",
":-P",
":-p",
":P",
":p",
":'(",
":[",
":-*",
":-.",
":-x",
"B-)",
"B)",
"x*O",
"(.)",
"(|)",
"X)",
"X|",
"X(",
"}:)",
"|)",
"}:(",
"|(",
"|-(",
"|-)",
"8)",
"8-)",
";)",
";-)",
0
};
if (regcomp (®ex, regtxt, REG_EXTENDED) != 0) {
printf ("Compilation error!\n");
return -1;
}
char **tmp;
for (tmp = table_smiley; *tmp != 0; tmp++)
{
int match = regexec (®ex, *tmp, 1, ®match, 0);
if (!match && regmatch.rm_so == 0)
{
printf ("Matched!\n");
}
else
printf ("Did _not_ match: %s\n", *tmp);
}
return 0;
}
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]