PDA

View Full Version : Removing all html tags except BOLD,ITALIC,UNDERLINE & UL,LI



Tejash
Nov 20th, 2009, 10:59 AM
Dear All,

Here I am facing one issue, that I want to removing all html tags except BOLD,ITALIC,UNDERLINE & UL,LI.

Means if my data is like,

<b><i> Test Data </b></i>
<input type="text" name="test">
<script>
function test()
{
.............
}
</script>



Then I want the following output....

<b><i> Test Data </b></i>
function test()
{
.............
}



Means I need the data with tags BOLD,ITALIC,UNDERLINE & UL,LI not any else tags.....


I have tried with this
strInputCode.replace(/<[^>]+>/ig,"");

but its removing all html tas that i dont want

Philip M
Nov 20th, 2009, 01:03 PM
Have a look at Kor's script at:-

http://www.codingforums.com/archive/index.php/t-86923.html

Also the below which looks as though it is what you want:-

http://blog.strictly-software.com/2009/01/cool-javascript-regular-expressions.html


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

Tejash
Nov 20th, 2009, 01:26 PM
Yes dear,

I have already seen that, by that the given tag will be remove.

but i want that given tag like bold,italic,underlin will not be removed...

I want all other tags removed....

If i wil follow kor's code, then i have to pass lots of tag name available for html....

Did u get my point.....????

Please help me dear....

Philip M
Nov 20th, 2009, 01:31 PM
Don't call me "dear" please. :( That carries offensive connotations.

The link I gave you allows you to specify the HTML tags which are allowed. If that will not do, then you are on your own.