Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

getting text bewtween 2 tags

Explorer ,
Aug 08, 2009 Aug 08, 2009

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

780
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 08, 2009 Aug 08, 2009

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

<cfoutput>
#mycode#
</cfoutput>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 08, 2009 Aug 08, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 08, 2009 Aug 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 08, 2009 Aug 08, 2009

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

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 08, 2009 Aug 08, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 09, 2009 Aug 09, 2009
LATEST

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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources