Results 1 to 2 of 2

Thread: remove HTML tags in javascript using regexp and replace

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    11
    Thanks
    0
    Thanked
    0 times in 0 posts

    remove HTML tags in javascript using regexp and replace

    Hi,

    i have a script i'm working on, a rich text box in DHTML which compiles the content in a hidden text field. I want to take it further to allow the number of characters to be counted, and i think the best way to do this is to take the length property of the compiled code from the hiddent text field on keypress. However this would include all the HTML tags e.g. <font face="verdana"> - so to remove these i need to convert the content of the field to a var, use a regexp to find all the <CONTENT> tags (anything within < and > ) and replace them with nothing - effectivly removing all the HTML content from the variable, and then rechecking its length. Can someone please tell me the regexp and replace command needed in javascript to remove ALL the HTML tags from a paragraph or so of HTML code

    Thank

    SP!KE

  2. #2
    Goat Boy
    Join Date
    Jul 2003
    Location
    Alexandra Park, London
    Posts
    2,428
    Thanks
    0
    Thanked
    0 times in 0 posts
    What language are you writing this in on the back end? You might be better off using an HTML parser. They exist for Java and Perl, and I'm sure there are libraries around for other languages,,,
    "All our beliefs are being challenged now, and rightfully so, they're stupid." - Bill Hicks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •