House of Fusion
Home of the ColdFusion Community

Search cf-talk

December 02, 2008

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

Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

Regex inside a loop

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Hi,
W Luke
05/12/03 07:14 A
<cfloop query="testQ">
Pascal Peters
05/12/03 07:36 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

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

05/12/2003 07:19 AM
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

05/12/2003 07:32 AM
Author:
will

No luck Ade...what could be wrong?  Would the contents of the query affect the regex?   Will

05/12/2003 07:36 AM
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

05/12/2003 07:55 AM
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

05/12/2003 08:59 AM
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

05/12/2003 08:02 AM
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

05/12/2003 08:23 AM
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

05/12/2003 08:54 AM
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

05/12/2003 09:41 AM
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

05/12/2003 09:56 AM
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 :


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

Mailing Lists