in reply to Re^4: Stripping HTML tags efficiently
in thread Stripping HTML tags efficiently

Okay, this time I just tested something on the command line, and it appears to work. At least for simple HTML with no confusing attributes in tags:

perl -le '$d = "<moose>elk</moose>"; $p = qr/<.*?>/; $d =~ s/$p/" " x length $1/ge; print $d'

The is even simpler than what I suggested previously:

But once again, one of the HTML parsers may do a better job at this.

Replies are listed 'Best First'.
Re^6: Stripping HTML tags efficiently
by agynr (Acolyte) on Dec 11, 2004 at 10:53 UTC
    Sir, I want any help using HTML:Parser only as the data to be parsed is not less than 8 MB. So it is not possible for regular expression to parse all the tags so fast as HTML Parser can do.