It is nothing.

This is not good code. I haven't really looked through it lately. Don't learn 
programming practice from it.

With that said, I think this shows how to use find to remove tags and (optionally) 
content

                <cfparam name="keepTagContent" default="0">
                <cfparam name="tag" default="FONT">
                <cfparam name="tstr" default="An example <FONT face='fgfg'>This should 
be gone</FONT> This should still be there.">

                <cfset findstr="<"&tag>
                <cfset endstr="</"&tag&">">
                <cfset tstr2=tstr>
                <cfset tnext=FindNoCase(findstr,tstr)>
                <cfif tnext NEQ 0>
                        <cfset tnewstr="">
                        <cfset tstart=0>
                        <cfset tcRow=1>
                        <cfloop condition="tstart LTE len(tstr)">
                                <cfset tnext=FindNoCase(findstr,tstr,tstart+1)>
                                <cfif tnext NEQ 0>
                                        <cfset tstart=tnext>
                                        <cfset tend=tstart>
                                        <cfset tagend=find(">",tstr,tnext+1)>
                                        <cfset 
tagstr=trim(mid(tstr,tnext,tagend-(tnext-1)))>
                                        <cfset tnexttag=FindNoCase(endstr, tstr 
,tend+1)>
                                        <cfif tnexttag NEQ 0>
                                                <cfset tend=tnexttag>
                                                <cfset 
tfoundstr=mid(tstr,tstart,tend-(tstart-1)+(len(endstr)-1))>
                                                <cfset tcRow=tcRow+1>
                                                <cfif keepTagContent eq 0>
                                                        <cfset 
tstr2=replace(tstr2,tfoundstr,'')>
                                                <cfelse>
                                                        <cfset 
tstr2=replace(tstr2,tfoundstr,'#mid(tfoundstr,len(tagstr)+1,(len(tfoundstr)-len(tagstr))-len(endstr))#')>
                                                </cfif>
                                        </cfif>
                                <cfelse>
                                        <!--- aint no more footnotes, so we are done 
--->
                                        <cfbreak>
                                </cfif>
                        </cfloop>
                </cfif>
                <cfset result=tstr2>



                <cfoutput>#tstr#<br>
                #result#<br></cfoutput>


>>> [EMAIL PROTECTED] 03/26/03 12:04PM >>>
No CFMX upgrade for a while unfortunately, will look into the refind (if
I get time!)

Cheers to Neil, Jerry and Ben, much appreciated 

-----Original Message-----
From: Ben Doom [mailto:[EMAIL PROTECTED] 
Sent: 26 March 2003 16:30
To: CF-Talk
Subject: RE: RegExp Help


The easy answer (for me) is to upgrade to CFMX, which allows
"non-greedy" matches, which are intended to do exactly that.

If you really need to do this, I'd use refind() to locate each instance
of the beginning and ending tags and loop over that, removing them as I
find them.

HTH

--  Ben Doom
    Programmer & General Lackey
    Moonbow Software, Inc

: -----Original Message-----
: From: David Collie (itndac) [mailto:[EMAIL PROTECTED] 
: Sent: Wednesday, March 26, 2003 11:17 AM
: To: CF-Talk
: Subject: RE: RegExp Help
:
:
: Hi all...
:
: All right guys I actually do want to take it a bit further if you
don't
: mind... at the moment I only have one set of tags per page... but I
was
: starting to think I could use this all over the place and it would be
: very handy...
:
: How would you go about ensuring that it only stripped out between the
: opening and closing tag (if there were multiple) and not the others as
: and not get the mucked up answer as listed below by Ben
:
: Cheers
:
: PS Subscription to CF_RegExp has left my inbox. And yes, they did seem
: like weird questions but I understand why now :-)
:
: -----Original Message-----
: From: Ben Doom [mailto:[EMAIL PROTECTED] 
: Sent: 26 March 2003 15:29
: To: CF-Talk
: Subject: RE: RegExp Help
:
:
: Just be aware that if you have a page like
:
: Between <ud_stripout>the waves</ud_stripout> and the shore
<ud_stripout>
: there's a boat</ud_stripout> here.
:
: You'll get
: Between  here.
: not
: Between  and the shore  here.
:
: Because that regex will strip /everything/ between the /first/ open
and
: the /last/ close.  Which is why some of us are asking wierd questions
: about it.
: :-)
:
:
: --  Ben Doom
:     Programmer & General Lackey
:     Moonbow Software, Inc
:
: : -----Original Message-----
: : From: David Collie (itndac) [mailto:[EMAIL PROTECTED] 
: : Sent: Wednesday, March 26, 2003 10:25 AM
: : To: CF-Talk
: : Subject: RE: RegExp Help
: :
: :
: : Hi Neil,  Thanks for getting back to me...
: :
: : Your RegExp has done the trick.... well under it and really need to
: : brush up on my RegExp skills but am always put off by the horrible
: ones
: : you see getting used!
: :
: : Much appreciated anyway :-)
: :
: :
: :
: : -----Original Message-----
: : From: Neil Middleton [mailto:[EMAIL PROTECTED] 
: : Sent: 26 March 2003 15:01
: : To: CF-Talk
: : Subject: RE: RegExp Help
: :
: :
: : <ud_stripout>.*</ud_stripout>
: :
: : I think, if not, nevermind...
: :
: : Neil
: :
: :
: : > Can anyone help me with the RegExp for stripping out content
: : > between two
: : > defined tags... ie
: : >
: : > <ud_stripout>
: : >   ...
: : >   Content to strip out
: : >   ...
: : > </ud_stripout>
: : >
: : > I would need it to strip out all the content and the tags
: : > themselves as
: : > well...
: :
: :
: :
:
: 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to