Skip to main content
Known Participant
August 8, 2009
Question

getting text bewtween 2 tags

  • August 8, 2009
  • 3 replies
  • 874 views

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

    This topic has been closed for replies.

    3 replies

    BKBK
    Community Expert
    Community Expert
    August 9, 2009

    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>

    August 8, 2009

    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?

    HulfyAuthor
    Known Participant
    August 8, 2009

    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.

    HulfyAuthor
    Known Participant
    August 8, 2009

    I guess I need some string replacement/search to search for the tags and then extract the code between them.

    Thanks

    Participant
    August 8, 2009

    if the code is stored in #mycode#, is there a problem with doing

    <cfoutput>
    #mycode#
    </cfoutput>