|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Regex inside a loop
Hi,W Luke 05/12/03 07:14 A Maybe the query scope is taking precedence in the output? Try:Adrian Lynch 05/12/03 07:19 A No luck Ade...what could be wrong? Would the contents of the query affect the regex?will 05/12/03 07:32 A <cfloop query="testQ">Pascal Peters 05/12/03 07:36 A Nope, neither did that work. What are my options? Enter to the DB, and have a scheduled task stripwill 05/12/03 07:55 A Will,Stephen Moretti 05/12/03 08:59 A This should work. Try scoping all your vars:Pascal Peters 05/12/03 08:02 A Thanks for the try, Pascal but sadly the same old story. There is one other method I've thought of,will 05/12/03 08:23 A will@lukrative.com will@lukrative.com,Ezine 05/12/03 08:54 A Thanks for the idea Zine. Yours caused errors, so I tried my more-basic version:will 05/12/03 09:41 A Look at the source in the browser. Are there actual <>'s or are there >Ben Doom 05/12/03 09:56 A
Author: W Luke
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
Author: Adrian Lynch
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
Author: will
No luck Ade...what could be wrong? Would the contents of the query affect the regex? Will
Author: Pascal Peters
<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
Author: 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! Will
Author: Stephen Moretti
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
Author: Pascal Peters
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
Author: will
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
Author: Ezine
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
Author: will
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
Author: Ben Doom
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 :
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||