View Single Post
Old 01-17-2013, 01:19 AM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,056 Times in 4,025 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Just to show how UTTERLY BRAINDEAD that code is, try this:
Code:
var txt = "In math, 3 < 5 is true and 10 > 12 is false";
alert( removeHtmlTag( txt, 9999 ) );
using that removeHtmlTag code, as written.

You get an alert of In math, 3 12 is false

The stupid code thinks that "< 5 is true and 10 >" is an HTML tag!!!

*********

Anyway, aside from the code being both braindead and ugly as pig snot, if you don't want to eliminate HTML tags from the blogposts, then you *could* simply change that function to
Code:
function removeHtmlTag( strx, chop ) { return strx; }
If you do want to remove HTML tags, then do it right:
Code:
function removeHtmlTag( strx, chop ) /* ignores chop! */
{
    var re = /\<\/?[a-z][^\>]*\>/ig;
    return strx.replace( re, "" );
}
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
joesruddock (01-18-2013)