Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Split QString with multi-character separator: Strange behavior

    General and Desktop
    2
    3
    1866
    Loading More Posts
    • 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
      Asperamanca last edited by

      I have an input string like this:
      "RelationID";"FilePath";"ContentType"
      and would like to split it into three items:

      • RelationID
      • FilePath
      • ContentType

      I first remove the leading an trailing double quote and then do:
      myStringList = myString.split(""";""");

      The actual output looks like this:

      • RelationID"
      • "FilePath"
      • "ContentType

      (note the extra double quotes).

      I thought the separator parts are removed on split. Any ideas?

      1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion last edited by

        Did you try with:

        myStringList = myString.split("\";\"");

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 1
        • jsulm
          jsulm Lifetime Qt Champion last edited by

          This:

          """;"""
          

          actually means: empty string + ";" + empty string

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 2
          • First post
            Last post