Skip to main content
Participant
June 1, 2015
Answered

How do I edit the text within a Coldfusion string?

  • June 1, 2015
  • 3 replies
  • 470 views

Hi! I have a ColdFusion variable which contains a URL:

For example, it looks like <iframe width="640" height="360" src="//www.youtube.com/embed/XXXXXX" frameborder="0" allowfullscreen></iframe>.


What I'd like to do is replace the width of "640" with that of "450" and the height of "360" with "253". I'm passing a string into an "if" statement which will change the variables if the conditions are met. I CANNOT change the variables before making it a string. I must change the variables.


What is the best way to do this in ColdFusion? I don't know this language (my expertise is more in JavaScript and PHP), so I appreciate all the help you could give me.


Thank you for your help!


BP

    This topic has been closed for replies.
    Correct answer EddieLotter

    Have a look at the Replace() function. It allows you to replace one substring with another.

    Cheers

    Eddie

    3 replies

    Participant
    June 2, 2015

    Thank you very much! The Replace() worked just fine.

    Dave Ferguson
    Participating Frequently
    June 1, 2015

    Can you share the code you are working with?  It is a hard question to answer when we don't know the context.

    Thanks,

    --Dave

    EddieLotter
    EddieLotterCorrect answer
    Inspiring
    June 1, 2015

    Have a look at the Replace() function. It allows you to replace one substring with another.

    Cheers

    Eddie

    Participant
    June 2, 2015

    Thank you very much! The Replace() worked just fine.