Hi
Can anyone tell how to remove html tags from a string in javascript.
Thanks.
how to remove html tags in javascript
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
viewtopic.php?t=25494
the regex used later in the thread (sorry about the formatting) can be used to correctly remove all tags.
the regex used later in the thread (sorry about the formatting) can be used to correctly remove all tags.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Code: Select all
var matches = Somestring.match(/regexp(In)Here/)- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
or even (after reading that thread) you need to do a search and replace as follows....
Just copy the regExp and replacement from the other thread and it'll work 
EDIT: Here..
Code: Select all
var newstring = oldString.replace(/yourRegexp/, 'YourReplacement')EDIT: Here..
Code: Select all
var newString = taggedString.replace(/#<.*?(\s+ї\w\W]+?(\s*=\s*(ї''"]?).*?\\3))*?>#s/, '')