Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. STD::String replace

STD::String replace

Scheduled Pinned Locked Moved ATL / WTL / STL
htmlquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    snir_ya
    wrote on last edited by
    #1

    Hi, The application i'm writing at the moment is multi-lingual so we're working with std::strings. I'm generating an html on-the-fly in my application. I do it by using place holders so i need an efficient "replace" function but i coulnd't find an efficient replace methond for std::strings. Does anybody have an idea? thanks in advance. Snir Singleton Technologies Ltd.

    I S R 3 Replies Last reply
    0
    • S snir_ya

      Hi, The application i'm writing at the moment is multi-lingual so we're working with std::strings. I'm generating an html on-the-fly in my application. I do it by using place holders so i need an efficient "replace" function but i coulnd't find an efficient replace methond for std::strings. Does anybody have an idea? thanks in advance. Snir Singleton Technologies Ltd.

      I Offline
      I Offline
      Igor Vigdorchik
      wrote on last edited by
      #2

      String class does have a replace method.

      R 1 Reply Last reply
      0
      • S snir_ya

        Hi, The application i'm writing at the moment is multi-lingual so we're working with std::strings. I'm generating an html on-the-fly in my application. I do it by using place holders so i need an efficient "replace" function but i coulnd't find an efficient replace methond for std::strings. Does anybody have an idea? thanks in advance. Snir Singleton Technologies Ltd.

        S Offline
        S Offline
        Stuart Dootson
        wrote on last edited by
        #3

        Define efficient - i.e. why std::string::replace isn't suitable. You may be better off generating a new string using original string and placeholder replacements, i.e. scan through the original string, copying it to the new one, and when you see a placeholder, copy the replacement text to the new string rather than the placeholder (which you (obviously) step over).

        1 Reply Last reply
        0
        • I Igor Vigdorchik

          String class does have a replace method.

          R Offline
          R Offline
          Roland Pibinger
          wrote on last edited by
          #4

          Igor Vigdorchik wrote:

          String class does have a replace method.

          std::string even has 9 replace functions! :~

          1 Reply Last reply
          0
          • S snir_ya

            Hi, The application i'm writing at the moment is multi-lingual so we're working with std::strings. I'm generating an html on-the-fly in my application. I do it by using place holders so i need an efficient "replace" function but i coulnd't find an efficient replace methond for std::strings. Does anybody have an idea? thanks in advance. Snir Singleton Technologies Ltd.

            R Offline
            R Offline
            Roland Pibinger
            wrote on last edited by
            #5

            snir_ya wrote:

            The application i'm writing at the moment is multi-lingual so we're working with std::strings.I'm generating an html on-the-fly in my application. I do it by using place holders so i need an efficient "replace" function but i coulnd't find an efficient replace methond for std::strings.

            You need to write a function that copies your string contents to a new string object thereby replacing all 'place holders' in one pass with the actual strings. Try find_first_of to find a place holder.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups