View Single Post
Old 10-08-2003, 04:03 AM   #61
Alexander Turcic
Fully Converged
Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.
 
Alexander Turcic's Avatar
 
Posts: 17,455
Karma: 10995944
Join Date: Oct 2002
Location: Switzerland
Device: Sony PRS-650 / Nexus 7 / Kindle PW
Quote:
Originally Posted by hacker
Speaking of regular expressions, here is one I wrote in my own perl web spider (used to fetch and convert webpages into Plucker format), that will strip Javascript and CSS style blocks from the page before it is parsed (since we don't deal with those elements, they're only taking up useless space in RAM at parse time, why not remove them!)

$content =~ s!<(s(?:cript|tyle))[^>]*>.*?</\1>!!gis

Works like a champ. Look at that beautiful backtracking and how I recycle the redundant parts of the regex, to combine two into one.

Perl++
Heh... nice one. Why not compete for the most complex regular expression
Alexander Turcic is offline