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

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

Regex inside a loop

  << 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:
W Luke
05/12/2003 07:14 AM

Hi, I'm just trying to strip HTML when looping over a query, and have a very basic regex - but for some reason, it just ignores it and refuses to work.  No errors, just a load of horrible HTML that I want stripped! I wonder if anyone can see where I'm going wrong?  #description# is the one that needs stripping.   <cfloop query="testQ"> <cfset description= #ReReplacenocase(description,"<[^>]*>","","ALL")#> <cfoutput><p><a href="#link#">#title#</a><br>#description#</p></cfoutput> </cfloop>   Thanks very much Will

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Adrian Lynch
05/12/2003 07:19 AM

Maybe the query scope is taking precedence in the output? Try: <cfloop query="testQ"> <cfset testQ.description= #ReReplacenocase(testQ.description,"<[^>]*>","","ALL")#> <cfoutput><p><a href="#link#">#title#</a><br>#testQ.description#</p></cfoutput> </cfloop> Ade Hi, I'm just trying to strip HTML when looping over a query, and have a very basic regex - but for some reason, it just ignores it and refuses to work.  No errors, just a load of horrible HTML that I want stripped! I wonder if anyone can see where I'm going wrong?  #description# is the one that needs stripping.   <cfloop query="testQ"> <cfset description= #ReReplacenocase(description,"<[^>]*>","","ALL")#> <cfoutput><p><a href="#link#">#title#</a><br>#description#</p></cfoutput> </cfloop>   Thanks very much Will

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
will
05/12/2003 07:32 AM

No luck Ade...what could be wrong?  Would the contents of the query affect the regex?   Will ----- Excess quoted text cut - see Original Post for more -----

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Pascal Peters
05/12/2003 07:36 AM

<cfloop query="testQ"> <cfset description= #ReReplacenocase(description,"<[^>]*>","","ALL")#> <cfoutput><p><a href="#link#">#title#</a><br>#variables.description#</p></cfoutput> </cfloop>   Hi, I'm just trying to strip HTML when looping over a query, and have a very basic regex - but for some reason, it just ignores it and refuses to work.  No errors, just a load of horrible HTML that I want stripped! I wonder if anyone can see where I'm going wrong?  #description# is the one that needs stripping.   <cfloop query="testQ"> <cfset description= #ReReplacenocase(description,"<[^>]*>","","ALL")#> <cfoutput><p><a href="#link#">#title#</a><br>#description#</p></cfoutput> </cfloop>   Thanks very much Will

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
will
05/12/2003 07:55 AM

Nope, neither did that work.  What are my options?  Enter to the DB, and have a scheduled task strip them periodically?  I can't understand why it's just being ignored though, nothing seems to work! Will ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Stephen Moretti
05/12/2003 08:59 AM

Will, > Nope, neither did that work.  What are my options?  Enter to the DB, > and have a scheduled task strip them periodically?  I can't understand > why it's just being ignored though, nothing seems to work! What's actually happening? Are you getting a display at all? Is it displaying but with the HTML still in the text? Have you tried doing a simple replace(), say replace the letter "e" with "$" throughout the text? <cfoutput query="testQ">     <cfset desc = ReplaceNoCase(testQ.description,"e","$","ALL")>     <p><a href="#testQ.link#">#testQ.title#</a><br>#variables.desc#</p> </cfoutput> Stephen

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Pascal Peters
05/12/2003 08:02 AM

This should work. Try scoping all your vars: <cfoutput query="testQ"> <cfset desc = ReReplacenocase(testQ.description,"<[^>]*>","","ALL")> <p><a href="#testQ.link#">#testQ.title#</a><br>#variables.desc#</p> </cfoutput>   Nope, neither did that work.  What are my options?  Enter to the DB, and have a scheduled task strip them periodically?  I can't understand why it's just being ignored though, nothing seems to work! Will ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
will
05/12/2003 08:23 AM

Thanks for the try, Pascal but sadly the same old story.  There is one other method I've thought of, so here goes: The query is formed by QueryNew & a structure.  The description field is entered as follows: StructInsert(RSS_Struct, "description", GetToken(rssDoc,  NextToken+1, "<>")); And this is from a CFC (http://www.cflib.org/udf.cfm?ID=813) which translates RSS items.  Could I strip the HTML *before* it's added to the query? Will

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Ezine
05/12/2003 08:54 AM

will@lukrative.com will@lukrative.com, sNoHTML = REReplace(REReplace(Replace(ReplaceNoCase(ReplaceNoCase(ReplaceNoCase(STRING VARIABLE," "," ", "all"),"<li>","-","all"),"&","and","all"),"#chr(13)##chr(10)#","#chr(13)##ch r(10)##chr(13)##chr(10)#","all"),"<[^>]+>","","all"),"[[:space:]]*#chr(13)## chr(10)#[[:space:]]*#chr(13)##chr(10)#","#chr(13)##chr(10)##chr(13)##chr(10) #","all"); This is code that I have used in multipart mail messages.. cleaning the HTML input.   Sometimes it does really strange things with the formatting though. Replace 'STRINGVARIABLE' with your token from the RSS feed, and insert 'sNoHTML' into the struct. -Zine Thanks for the try, Pascal but sadly the same old story.  There is one other method I've thought of, so here goes: The query is formed by QueryNew & a structure.  The description field is entered as follows: StructInsert(RSS_Struct, "description", GetToken(rssDoc,  NextToken+1, "<>")); And this is from a CFC (http://www.cflib.org/udf.cfm?ID=813) which translates RSS items.  Could I strip the HTML *before* it's added to the query? Will

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
will
05/12/2003 09:41 AM

Thanks for the idea Zine.  Yours caused errors, so I tried my more-basic version: theone = GetToken(rssDoc,  NextToken+1, "<>");            desc = ReReplacenocase(theone,"<[^>]*>","","ALL");          // add the title to the structure StructInsert(RSS_Struct, "description", theone); This didn't cause any errors, but neither did it work!  Still ridden with HTML tags.  I'm thinking that because gettoken is using "<>" as its' delimiters, that might be causing problems with my regex which is (i think) looking for anchors and trying to remove them. Bizarre...any other clever ideas? Will >This is code that I have used in multipart mail messages.. cleaning the HTML >input.   Sometimes it does really strange things with the formatting though. >Replace 'STRINGVARIABLE' with your token from the RSS feed, and insert >'sNoHTML' into the struct. > >-Zine

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Ben Doom
05/12/2003 09:56 AM

Look at the source in the browser.  Are there actual <>'s or are there > and <? the ever-present plug: http://www.houseoffusion.com/cf_lists/index.cfm?method=threads&forumid=21 For all your RegEx needs, the HoF CF-RegEx list! --  Ben Doom     Programmer & General Lackey     Moonbow Software, Inc : -----Original Message----- : From: will@lukrative.com will@lukrative.com [mailto:will@lukrative.com] : Sent: Monday, May 12, 2003 9:30 AM : To: CF-Talk : Subject: Regex inside a loop : : : Thanks for the idea Zine.  Yours caused errors, so I tried my : more-basic version: : : theone = GetToken(rssDoc,  NextToken+1, "<>"); : : desc = ReReplacenocase(theone,"<[^>]*>","","ALL"); : : // add the title to the structure : : StructInsert(RSS_Struct, "description", theone); : : This didn't cause any errors, but neither did it work!  Still : ridden with HTML tags.  I'm thinking that because gettoken is : using "<>" as its' delimiters, that might be causing problems : with my regex which is (i think) looking for anchors and trying : to remove them. : : Bizarre...any other clever ideas? : : Will : : >This is code that I have used in multipart mail messages.. : cleaning the HTML : >input.   Sometimes it does really strange things with the : formatting though. : >Replace 'STRINGVARIABLE' with your token from the RSS feed, and insert : >'sNoHTML' into the struct. : > : >-Zine :


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

Search cf-talk

May 24, 2012

<<   <   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 31     

Designer, Developer and mobile workflow conference