|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
RegEx HelpI need some assistance with some RegEx.
My goal is to replace the word "mentor" that is not inside of a HTML tag with the word "teacher". Here is what I have so far... <cfsavecontent variable="variables.pageContent"> <a href="mentorLink.cfm">this is the mentor mentoring link</a> this is my mentor. <input type="text" name="foobar" value="mentor"> </cfsavecontent> <cfset variables.pageContent = reReplace(variables.pageContent,"mentor(?=([[:space:]]|[[:punct:]]))","teacher","all")> <cfoutput>#variables.pageContent#</cfoutput> Desired Outout..... <a href="mentorLink.cfm">this is the teacher mentoring link</a> this is my teacher. <input type="text" name="foobar" value="mentor"> Thanks, -- John Blayter (303) 325-1979 john@... http://www.blayter.com/john/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1106 Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user837.14401.21 |
|
|
Re: RegEx HelpProbably not the best way, but this will work (assuming you always have
surrounding tags): <cfloop condition="REFind('>([^<]*)\bmentor\b([^<]*)<',variables.PageContent )"> <cfset variables.PageContent = REReplace ( variables.PageContent , ">([^<]*)\bmentor\b([^<]*)<" , ">\1teacher\2<" , "all" )/> </cfloop> Note the use of \b - that's a zero-width word boundary, and avoids the space/punct stuff you had. On Jan 14, 2008 9:45 PM, John Blayter <jblayter@...> wrote: > I need some assistance with some RegEx. > > My goal is to replace the word "mentor" that is not inside of a HTML tag > with the word "teacher". > > Here is what I have so far... > > <cfsavecontent variable="variables.pageContent"> > <a href="mentorLink.cfm">this is the mentor mentoring link</a> > this is my mentor. > <input type="text" name="foobar" value="mentor"> > </cfsavecontent> > <cfset variables.pageContent = reReplace(variables.pageContent > ,"mentor(?=([[:space:]]|[[:punct:]]))","teacher","all")> > <cfoutput>#variables.pageContent#</cfoutput> > > > Desired Outout..... > <a href="mentorLink.cfm">this is the teacher mentoring link</a> > this is my teacher. > <input type="text" name="foobar" value="mentor"> > > > Thanks, > > -- > John Blayter > (303) 325-1979 > john@... > http://www.blayter.com/john/ > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/RegEx/message.cfm/messageid:1107 Subscription: http://www.houseoffusion.com/groups/RegEx/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user837.14401.21 |
| Free embeddable forum powered by Nabble | Forum Help |