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. Split string with space but ignore when in quotes
Servers for Qt installer are currently down

Split string with space but ignore when in quotes

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 2.4k 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.
  • M Offline
    M Offline
    Maaz Momin
    wrote on 28 Jan 2020, 15:04 last edited by Maaz Momin
    #1

    Hi,

    I am facing a problem when splitting a string.

    Input: /number:123 /alphabets:"Good Morning \"Sam\"" /alphanumeric:" 'A' @ 123 \"abc\"" new open

    Expected output:
    1- /number:123
    2- /alphabets:Good Morning \"Sam\"
    3-/alphanumeric: 'A' @ 123 \"abc\"
    4-new
    5-open

    Can somebody please help me here?

    J 1 Reply Last reply 28 Jan 2020, 15:10
    0
    • M Maaz Momin
      28 Jan 2020, 15:04

      Hi,

      I am facing a problem when splitting a string.

      Input: /number:123 /alphabets:"Good Morning \"Sam\"" /alphanumeric:" 'A' @ 123 \"abc\"" new open

      Expected output:
      1- /number:123
      2- /alphabets:Good Morning \"Sam\"
      3-/alphanumeric: 'A' @ 123 \"abc\"
      4-new
      5-open

      Can somebody please help me here?

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 28 Jan 2020, 15:10 last edited by J.Hilk
      #2

      @Maaz-Momin
      split also allows for regular expressions
      https://doc.qt.io/qt-5/qstring.html#split-3

      Just a matter of regexp black magic


      googles black magic:
      https://stackoverflow.com/questions/9577930/regular-expression-to-select-all-whitespace-that-isnt-in-quotes


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      M 1 Reply Last reply 29 Jan 2020, 06:36
      6
      • J J.Hilk
        28 Jan 2020, 15:10

        @Maaz-Momin
        split also allows for regular expressions
        https://doc.qt.io/qt-5/qstring.html#split-3

        Just a matter of regexp black magic


        googles black magic:
        https://stackoverflow.com/questions/9577930/regular-expression-to-select-all-whitespace-that-isnt-in-quotes

        M Offline
        M Offline
        Maaz Momin
        wrote on 29 Jan 2020, 06:36 last edited by
        #3

        @J-Hilk Thanks for pointing that out. I was able to resolve my issue. Best Regards.

        1 Reply Last reply
        2

        1/3

        28 Jan 2020, 15:04

        • Login

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