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. C / C++ / MFC
  4. string (replace)-newbie

string (replace)-newbie

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 3 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.
  • A Offline
    A Offline
    antonaras
    wrote on last edited by
    #1

    Hi again guys i have this simple question i have a string that holds some text string text; i want to search the string and replace any ("&nbs" with a space) if i use the string.replace("&nbs"," ") it doesn't work what else do i need to specify for the function to work? Any other ways to do it? Thanks a lot

    C D 2 Replies Last reply
    0
    • A antonaras

      Hi again guys i have this simple question i have a string that holds some text string text; i want to search the string and replace any ("&nbs" with a space) if i use the string.replace("&nbs"," ") it doesn't work what else do i need to specify for the function to work? Any other ways to do it? Thanks a lot

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      something like this: find the first "&nbs" copy the left part of the string (ie. before the &nbs) to a temp string add a " " to the temp in a loop: find the next "&nbs" in the remaining (right side) string if none found, add the remaing string to temp, and return temp add the left part to the temp add a " " to the temp repeat the loop Cleek | Image Toolkits | Thumbnail maker

      A 1 Reply Last reply
      0
      • C Chris Losinger

        something like this: find the first "&nbs" copy the left part of the string (ie. before the &nbs) to a temp string add a " " to the temp in a loop: find the next "&nbs" in the remaining (right side) string if none found, add the remaing string to temp, and return temp add the left part to the temp add a " " to the temp repeat the loop Cleek | Image Toolkits | Thumbnail maker

        A Offline
        A Offline
        antonaras
        wrote on last edited by
        #3

        Thanks a lot Chris Losinger good clear steps thanks a lot

        1 Reply Last reply
        0
        • A antonaras

          Hi again guys i have this simple question i have a string that holds some text string text; i want to search the string and replace any ("&nbs" with a space) if i use the string.replace("&nbs"," ") it doesn't work what else do i need to specify for the function to work? Any other ways to do it? Thanks a lot

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          antonaras wrote:

          if i use the string.replace("&nbs"," ") it doesn't work

          What dosn't work? Does the compiler/linker complain? Is an exception thrown? Do any replacements happen?


          "The largest fire starts but with the smallest spark." - David Crow

          "Judge not by the eye but by the heart." - Native American Proverb

          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