Copy link to clipboard
Copied
Hi,
I have a block of code like this
<div class="leftCol>
<!---start--->
this is the code i need to get
<!---end--->
</div>
I need to get everything between the start and end coments. if this is stored in the variable #myCode# how can I can I achive this?
Thanks,
R
Copy link to clipboard
Copied
if the code is stored in #mycode#, is there a problem with doing
<cfoutput>
#mycode#
</cfoutput>
Copy link to clipboard
Copied
can you please clarify "get"
do you mean you need to get the code between those tags and store it in #myCode# or is the code already in #myCode# and you just need to output it?
Copy link to clipboard
Copied
there are lines of code before and after the tags. I want to remove this and be left with what is between the tags.
thanks.
Copy link to clipboard
Copied
I guess I need some string replacement/search to search for the tags and then extract the code between them.
Thanks
Copy link to clipboard
Copied
So basically yes, you want to get what is between the tags then store it in your #myCode# variable.
and yes - string replacement...
you might be able to reaad the whole file into a variable, count the caharacters and find the <!--start--><!--end--> tags and replace everything else with nothing.... but that seems sloppy to me, there should be better ways
-sean
Copy link to clipboard
Copied
If it's just text(and no code), then cfsavecontent might be what you need
<div class="leftCol">
<cfsavecontent variable="myCode">
blah blah blah
</cfsavecontent>
</div>