[SP-pm] Função que verifica dados HTML

Daniel de Oliveira Mantovani daniel.oliveira.mantovani at gmail.com
Thu Jan 14 05:03:33 PST 2010


Ufa, agora eu acho que ele não vai usar expressões regulares :)
Gabriel++

2010/1/14 Daniel de Oliveira Mantovani <daniel.oliveira.mantovani em gmail.com>:
> Não use expressões regulares para isso
> Não use expressões regulares para isso
> Não use expressões regulares para isso
> Não use expressões regulares para isso
> Não use expressões regulares para isso
>
> *****The most correct way***** (albeit not the fastest) is to use HTML::Parser
> from CPAN.  Another mostly correct way is to use HTML::FormatText which
> not only removes HTML but also attempts to do a little simple
> formatting of the resulting plain text.
>
> Você sabe usa o CPAN Fernando ?
> Um cara escreveu um artigo de como usar, vê se te ajuda:
>
> http://www.perl.org.br/Artigos/ArtigoDanielMantovani2009x12x02
>
> []'s
>
> 2010/1/14 Gabriel Andrade <gabiruh em gmail.com>:
>> 2010/1/14 Fernando <fernandolouis em terra.com.br>:
>>> Amigos, a função “strip_tags()” na linguagem PHP, previne entrada maliciosa
>>> de tags HTML. Qual seria a equivalente função aplicada à PERL?
>>
>> Solução simples, rápida, porca, restrita, não-extensível e
>> anti-padrões (você pediu que fosse equivalente ao PHP não foi? ):
>>
>>   s/<(?:[^>'"]*|(['"]).*?\1)*>//gs
>>
>> Outra forma mais elegante, inteligente, extensível, testada e
>> documentada seria usar módulos do perl específicos pra esse tipo de
>> problema como HTML::FormatText ou HTML::Restrict.
>>
>> A título de curiosidade, o strip_tags() do php 5 se caga todo com
>> expressões como:
>>
>>   <script>if (a<b && a>c)</script>
>>
>> Fontes:
>> $ perldoc -q 'remove HTML from a string'
>> http://search.cpan.org/search?query=strip+html&mode=all
>> _______________________________________________
>> SaoPaulo-pm mailing list
>> SaoPaulo-pm em pm.org
>> http://mail.pm.org/mailman/listinfo/saopaulo-pm
>>
>
>
>
> --
> "If you’ve never written anything thoughtful, then you’ve never had
> any difficult, important, or interesting thoughts. That’s the secret:
> people who don’t write, are people who don’t think."
>



-- 
"If you’ve never written anything thoughtful, then you’ve never had
any difficult, important, or interesting thoughts. That’s the secret:
people who don’t write, are people who don’t think."


More information about the SaoPaulo-pm mailing list