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. QString question
QtWS25 Last Chance

QString question

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 1.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.
  • cmessineoC Offline
    cmessineoC Offline
    cmessineo
    wrote on last edited by
    #1

    Hi, how would I remove all carriage returns , tabs, line feeds ect from a QString. I just want all character and number data.

    Thanks

    R 1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      One way would be to use QString::replace(), use a QRegExp to find the characters/character sequences you mention, and replace them with "".

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

        [quote author="Andre" date="1314563158"]One way would be to use QString::replace(), use a QRegExp to find the characters/character sequences you mention, and replace them with "".[/quote]

        "QString::remove()":http://doc.qt.nokia.com/4.7-snapshot/qstring.html#remove would be equivalent, too. You also might consider the possibility of using "QString::simplified()":http://doc.qt.nokia.com/4.7-snapshot/qstring.html#simplified to cull out a lot of extraneous white space first, if it would help in building your QRegExp.

        Software Engineer
        My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

        1 Reply Last reply
        1
        • cmessineoC cmessineo

          Hi, how would I remove all carriage returns , tabs, line feeds ect from a QString. I just want all character and number data.

          Thanks

          R Offline
          R Offline
          RamaKrishna02
          wrote on last edited by
          #4

          Hi ,
          U can use the RegExp and String.simplified() also.

          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