House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Regular Expression and HTML

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
jean-marc bottin
06/03/2004 09:46 AM

I got a RE that I have modified in order to parse some HTML and to only keep tag starting with a “<input”, “<select” or “<textarea, however I am struggling with it. I have some HTML: <table width="100%"  border="0" cellspacing="0" cellpadding="0">   <tr>         <td><input type="file" name="file_1" value="file_1"></td>     <td><input type="text" name="text_1" value="text_1" size="12" maxlength="18"></td>   </tr>   <tr>         <td colspan="2"><textarea name="textarea_1" cols="12" rows="5" wrap="hard"></textarea></td>       </tr>   <tr>     <td>   <input type="radio" name="radio_1" value="1">   <input type="radio" name="radio_1" value="2">   <input type="radio" name="radio_1" value="3"></td>     <td>   <select name="select_1">     <option value="value11" selected>a</option>     <option value="value12">b</option>     <option value="value13">c</option>     <option value="value14">d</option>   </select>   </td>   </tr>   <tr>     <td><input type="submit" name="submit_1" value="submit_1"></td>   <td><input type="reset" name="reset_1" value="reset_1"></td>   </tr> </table> After using the RE I get that: cellSpacing=0 cellPadding=0 width="100%" border=0> ----- Excess quoted text cut - see Original Post for more ----- colSpan=2><TEXTAREA name=textarea_1 rows=5 wrap=hard cols=12></TEXTAREA>>> ----- Excess quoted text cut - see Original Post for more ----- I managed to take out nearly all the HTML but the closing tag are still there and the inside attributes are still there too, what do I miss here. I am not very familiar with RE and I am going crazy. Here is my RE: <cfset cleanFromHTML = REReplaceNoCase("#form.stFormStruct#", "(<\/?)(a(bbr|cronym|ddress|pplet|rea)?|b(ase(font)?|do|ig|lockquote|ody|r|utton)?|c(aption|enter|ite|lass|(o(de|l(group)?)))|d(d|el|fn|i(r|v)|l|t)|em|f(ieldset|o(nt|rm)|rame(set)?)|h([1-6]|ead|r|tml)|i(frame|mg|sindex)|kbd|l(abel|egend|i(nk)?)|m(ap|e(nu|ta))|no(frames|script)|o(bject|l)|p(aram|re)?|q|s(amp|cript|mall|pan|t(r(ike|ong)|yle)|u(b|p))|t(able|body|d|foot|h|itle|r|t)|u(l)?|var)", "", "all")> Thanks, Jean-Marc

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Pascal Peters
06/03/2004 09:53 AM

Add [^>]*> at the end of the regexp. If you are on mx, you can write a shorter regexp!! ----- Excess quoted text cut - see Original Post for more ----- )|d(d|el|fn|i(r|v)|l|t)|em|f(ieldset|o(nt|rm)|rame(set)?)|h([1-6]|ead|r| tml)|i(frame|mg|s> index)|kbd|l(abel|egend|i(nk)?)|m(ap|e(nu|ta))|no(frames|scrip > t)|o(bject|l)|p(aram|re)?|q|s(amp|cript|mall|pan|t(r(ike|ong)| yle)|u(b|p))|t(able|body|d|foot|h|itle|r|t)|u(l)?|var)", "", "all")> > > Thanks, > > Jean-Marc

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
jean-marc bottin
06/03/2004 10:09 AM

It works, thank you. Jean-Marc

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
jean-marc bottin
06/03/2004 10:06 AM

It works, thank you very much. Jean-Marc

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Pascal Peters
06/03/2004 10:11 AM

On mx: regexp = "<(?!/?(input|textarea|select|option)\b).*?>"; newtxt = REReplaceNoCase(txt,regexp,"","all"); > It works, thank you very much. > > Jean-Marc

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jean-Marc Bottin
06/03/2004 10:32 AM

Even better, wouaw! Thanks, Jean-Marc -----Message d'origine----- De : Pascal Peters [mailto:ppeters@lrt.be] Envoyé : jeudi 3 juin 2004 16:08 À : CF-Talk Objet : RE: Regular Expression and HTML On mx: regexp = "<(?!/?(input|textarea|select|option)\b).*?>"; newtxt = REReplaceNoCase(txt,regexp,"","all"); > It works, thank you very much. > > Jean-Marc > >   _____  


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

September 06, 2010

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30