Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ReReplace question 1

Status
Not open for further replies.

peterswan

Programmer
Sep 25, 2002
263
0
0
US
Hello,

I need to see if a chunk of text contains any one of the following:
P1,P2,P3,P4,P5,P6,P7,P8,P9
and if it does, put in a <br> before this instance.
So the logic of the ReReplace is bascically:
Replace any instance of
P1,P2,P3,P4,P5,P6,P7,P8,P9
with a <br> tag, plus itself.
Can I do this with ReReplace?

Thanks,[glasses]

Peter
 
OK,
So far I've got this, but it sure is a lot of code:

<cfset Comment_text = ReReplace(qrybase.mc_gentext,"P1", "<br>P1", "ALL")>
<cfset Comment_text = ReReplace(comment_text,"P2", "<br>P2", "ALL")>
<cfset Comment_text = ReReplace(comment_text,"P3", "<br>P3", "ALL")>
<cfset Comment_text = ReReplace(comment_text,"P4", "<br>P4", "ALL")>
<cfset Comment_text = ReReplace(comment_text,"P5", "<br>P5", "ALL")>
<cfset Comment_text = ReReplace(comment_text,"P6", "<br>P6", "ALL")>
<cfset Comment_text = ReReplace(comment_text,"P7", "<br>P7", "ALL")>
<cfset Comment_text = ReReplace(comment_text,"P8", "<br>P8", "ALL")>
<cfset Comment_text = ReReplace(comment_text,"P9", "<br>P9", "ALL")>
<cfoutput>#comment_text#</cfoutput>

Any ideas?
 
Same thing, just less code (and I used Replace instead of REReplace):
Code:
<cfset Comment_text = qrybase.mc_gentext>
<cfloop index="i" list="P1,P2,P3,P4,P5,P6,P7,P8,P9">
  <cfset Comment_text = [red]Replace[/red](Comment_text,"#i#", "<br>#i#", "ALL")>
</cfloop>

<cfoutput>#comment_text#</cfoutput>


Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top