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
Forum Updated to NodeBB v4.3 + New Features

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.
  • Maaz MominM Offline
    Maaz MominM Offline
    Maaz Momin
    wrote on 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.HilkJ 1 Reply Last reply
    0
    • Maaz MominM Maaz Momin

      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.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on 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.

      Maaz MominM 1 Reply Last reply
      6
      • J.HilkJ J.Hilk

        @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

        Maaz MominM Offline
        Maaz MominM Offline
        Maaz Momin
        wrote on 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

        • Login

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