1 Reply Latest reply on Nov 9, 2009 3:20 AM by oggex

    RegExp for replacing specific HTML tags.

    Dileep_NR Level 2

      Hi All,

       

      I need to replace some of the HTML tags in flex.

       

      for eg:-

      in the follwing html i have to replace "span","div" and "a"

      <h2>AAAAAAAAA<br /><span >BBBBBBBBBBB</span></h2><div><p>QQQQQQ</p><p>EE<br />FFFF<br />TTT<br /></p

      <a href="#">Click</a>

      </div>

        • 1. Re: RegExp for replacing specific HTML tags.
          oggex
          input = "yor html string";
          var urlPattern:RegExp = new RegExp("/(<a)(.*)(</a)/","ig");
          var result:String = input.replace(urlPattern, "<b$2</b");  
          
          var urlPattern2:RegExp = new RegExp("/(<div)(.*)(</div)/","ig");
          var result2:String = result.replace(urlPattern2, "<table$2</table");  
          
          and so on....
          
          

          hope this helps ...