Re: Remove Markups from string



Em Mon, 20 Jan 2003 17:20:46 -0500, Tristan Van Berkom <vantr touchtunes com> escreveu:

man strstr();

and see functions in:

#include <string.h>


Cheers,
              -Tristan


Hi,

works fine but it will fail if the user string contains '</' ... any suggestion ?

 --- BOC --- (Begin Of Code)

char *clear_markup (char *string)
{
        char *value = NULL;
        int i, ntags = 0;
        
        for (i = 0; i < strlen (string); i++) 
                if ((string[i] == '<') && (string[i + 1] == '/')) ntags++;

        if (ntags == 0) return strdup (string);

        for (i = 0; i < ntags; i++) { value = strchr (string, '>'); value++; }

        for (i = 0; i < strlen (value); i++)
                if (value[i] == '<') { value[i] = '\0'; break; }

        return strdup (value);
}

 --- EOC --- (End Of Code)

[]'s

-- 
André Casteliano
Analista de Sistemas e Programador

+-=-=[ digitalcoder users sourceforge net]=-=-+
[ Linux User: # 178853  Machine: # 79923      ]
[ Linux Heavy User - Powered by Slackware 8.1 ]
+-=-=[ www.geocities.com/andrecasteliano ]=-=-+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]