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. Filter characters from a string
Forum Updated to NodeBB v4.3 + New Features

Filter characters from a string

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.5k Views 2 Watching
  • 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
    Marty
    wrote on last edited by
    #1

    Hello !

    I am working on a client app that communicates with a device via ethernet over TCP.
    I send it a string command and i get back a string response.

    Among the commands and answers, there are control characters and meta-codes. Those are the ASCII characters between 0x60 and 0x7f.

    How can i chop every character within this range from my response string ?

    thanks a lot.

    K 1 Reply Last reply
    0
    • M Marty

      Hello !

      I am working on a client app that communicates with a device via ethernet over TCP.
      I send it a string command and i get back a string response.

      Among the commands and answers, there are control characters and meta-codes. Those are the ASCII characters between 0x60 and 0x7f.

      How can i chop every character within this range from my response string ?

      thanks a lot.

      K Offline
      K Offline
      koahnig
      wrote on last edited by koahnig
      #2

      @Marty said:

      Among the commands and answers, there are control characters and meta-codes. Those are the ASCII characters between 0x60 and 0x7f.

      How can i chop every character within this range from my response string ?

      Brute force can help there. Since you know the ASCII range to exclude you can simply do it with an if statement. Also the good old C routines might help isalpha and fellows.

      Alternative for more sophisticated stuff there is QRegExp or the newer version QRegularExpression.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Marty
        wrote on last edited by
        #3

        hum... i imagined there was an easier way to achieve this, like removing a bunch of character at once
        but thanks ! i will have a look

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          Regular expression would be the right choice then. However, you need to be prepared that there is certainly a learning curve.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Marty
            wrote on last edited by
            #5

            yes, this seems a good way to go.
            now all i see is filtering by matching a pattern
            i don't have any fixed pattern, i would like to remove characters wherever they appear in the string

            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