Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > regexp strip html

Reply
Thread Tools

regexp strip html

 
 
Une bévue
Guest
Posts: n/a
 
      03-26-2006
i have a regexp able to strip html :

/<[^>]*>/

however, between <script and </script> all the "text is preserved, tjen
i've tried :

def stripHTML
# self.gsub(/<\S[^><]*>/, '')
self.gsub(/\A.*<body [^>]*>(.*)<\/body>\s*\Z/, '\1').gsub(/<[^>]*>/,
'')
end

without success : the various javascript functions are kept ?

what's my error here ?

--
une bévue
 
Reply With Quote
 
 
 
 
Paul Battley
Guest
Posts: n/a
 
      03-27-2006
T24gMjYvMDMvMDYsIFVuZSBiw6l2dWUgPHBlcmUubm9lbEBsYX BvbmllLmNvbS5pbnZhbGlkPiB3
cm90ZToKPiBpIGhhdmUgYSByZWdleHAgYWJsZSB0byBzdHJpcC BodG1sIDoKPgo+IC88W14+XSo+
Lwo+Cj4gaG93ZXZlciwgYmV0d2VlbiA8c2NyaXB0IGFuZCA8L3 NjcmlwdD4gYWxsIHRoZSAidGV4
dCBpcyBwcmVzZXJ2ZWQsIHRqZW4KLi4uCj4gd2hhdCdzIG15IG Vycm9yIGhlcmUgPwoKTG9vayBh
dCBpdCB0aGlzIHdheTogeW91IGhhdmUgJzxzY3JpcHQ+SmF2YX NjcmlwdDwvc2NyaXB0PicuIFlv
dQpyZW1vdmUgZXZlcnl0aGluZyBiZXR3ZWVuIGFuZ2xlIGJyYW NrZXRzLiBZb3Ugc3RpbGwgaGF2
ZSAnSmF2YXNjcmlwdCcsCmJlY2F1c2UgdGhhdCdzIG5vdCBhY3 R1YWxseSBpbnNpZGUgPC4uLj4u
CgpUaGUgc2ltcGxlc3Qgc29sdXRpb24gaXMgcHJvYmFibHkgdG 8gZG8gc29tZXRoaW5nIGxpa2Ug
dGhpcyBiZWZvcmUKc3RyaXBwaW5nIG91dCB0aGUgcmVtYWluaW 5nIHRhZ3M6Cgpnc3ViKC88c2Ny
aXB0Lio/PC9zY3JpcHQ+L2ltLCAnJykKClBhdWwuCg==


 
Reply With Quote
 
 
 
 
Une bévue
Guest
Posts: n/a
 
      03-27-2006
Paul Battley <(E-Mail Removed)> wrote:

> The simplest solution is probably to do something like this
> before

stripping out the remaining tags:

gsub(/<script.*?</script>/im,
> '')


yes, sounds clever ))

--
une bévue
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
strip all but second second line from bottom and then strip that!!!! yelipolok Perl Misc 4 01-27-2010 08:14 AM
[regexp] How to convert string "/regexp/i" to /regexp/i - ? Joao Silva Ruby 16 08-21-2009 05:52 PM
strip and its evil brother strip! Aquila Ruby 35 03-31-2005 04:10 AM
RegExp to strip accents while ignoring case Jon Maz ASP .Net 4 06-15-2004 08:58 AM
How to strip HTML markup from string? Michal A. Valasek ASP .Net 2 08-12-2003 06:39 AM



Advertisments