Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to extract two strings difference

How to extract two strings difference

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 561 Views
  • 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
    Anonymous_Banned275
    wrote on last edited by
    #1

    OK, I can RTFM but there are way too many options.
    I am asking if somebody in this forum "been there, done that " - preferably in C/C++.

    I am NOT looking for comparing strings - I need to extract the actual difference between them .
    How about "finding sub-string in string " and return what is left over or use regular expression.
    Would iterating thru both strings and returning "no match" work?
    I am asking for ideas

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      OK, I can RTFM but there are way too many options.

      groan

      I am NOT looking for comparing strings - I need to extract the actual difference between them .

      Please define "difference" without comparing strings.

      1 Reply Last reply
      3
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        std::string::find()
        std::string::erase()

        A 1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          What constitutes a difference in your case? What result would you expect when comparing "Hello world" with "The answer is 42"? Do you mean compare on word or letter basis? Is whitespace important? What about strings of different lengths? Do you want a list of different strings or offsets into either of the string as a result?

          You need to be a lot more specific for any useful suggestions. A real life example with input strings and expected result would be best.

          1 Reply Last reply
          3
          • Kent-DorfmanK Kent-Dorfman

            std::string::find()
            std::string::erase()

            A Offline
            A Offline
            Anonymous_Banned275
            wrote on last edited by
            #5

            @Kent-Dorfman Brilliant , simply brilliant. Thanks

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved