2 Replies Latest reply: Feb 7, 2014 6:33 PM by huangxinghui RSS

    Multiple replace in string

    Craberoid

      Hi!

      I have a string like

      /series/%seriesName%?pipeKey=%pipeKey%&kmbegin=%kmFrom%&kmend=%kmTo%&modekey=%modeKey%" 
      

       

      And I want to replace variables with appropriate values. Now I do this with next code:

      myString.replace("%seriesName%", seriesName).replace("%pipeKey%", pipeKey).replace("%kmFrom%", kmFrom).replace("%kmTo%", kmTo).replace("%modeKey%", modeKey);
      

       

      Maybe there is shorter and prettier algorithm exists?

       

      Thank you!