Using regex to delete part of an html string with given start and end

Discussion in 'JavaScript' started by rnilsson, Apr 23, 2013.

  1. #1
    I read all the regex posts first, before starting this post.

    I need to process a large string of html from a generated page, removing some navigation elements; I can add comments as placeholders and markers as needed before generating.

    I've attempted to replace the string starting with the inserted comment "<!-- SOBs -->" and ending with "<!-- EOBs -->" but I am failing. I assume it is not something as simple as:

    tempString=tempString.replace(/<!-- SoBs -->.*<!-- EoBs -->/gi, " ");
     
    rnilsson, Apr 23, 2013 IP
  2. chatvana

    chatvana Greenhorn

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #2
    check whether this helps you : http://ostermiller.org/findcomment.html
     
    chatvana, Apr 29, 2013 IP