How do I delete part of the String?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eman ali
    New Member
    • Nov 2012
    • 1

    How do I delete part of the String?

    Hello,
    my problem is quite simple to explain.
    I have the following string:
    "type computer {dell}"
    and I want to remove the {dell}
    So that the output on the screen type computer
    Or delete any clause between the two brackets {}
    How do i do that ?
    Thanks for your help.
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    your requirement is not very much clear. there is lots of if issue. anyway the simplest method would be search first { then search } and finally copy the part out of that range.

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      Look at the replace function using iteration.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        You can download a regex library or you can build a rudimentary one for you purposes. You just need to find the indexes of your start and end characters and substring out the pieces you want.

        Comment

        • johny10151981
          Top Contributor
          • Jan 2010
          • 1059

          #5
          you can download pcre library. it is written in C for pearl equivalent regular expression.

          Comment

          • whodgson
            Contributor
            • Jan 2007
            • 542

            #6
            as Rabbit says:
            with the C++ <string> header file
            if string s="type computer {deli}"
            and string s1=s(erase 14,6)then s1= "type computer "

            Comment

            Working...