Results 1 to 4 of 4

Thread: removing carriage return from QString

  1. #1
    Join Date
    Feb 2009
    Posts
    22
    Thanks
    4
    Qt products
    Qt3 Qt4

    Default removing carriage return from QString

    I have a QString (which is a URL) from which i want to remove invalid characters like carriage return (\n), tab (\t), \r etc

    I tried:
    Qt Code:
    1. urlString.remove(QRegExp("[\n\t\r]"));
    To copy to clipboard, switch view to plain text mode 

    But this doesn't work.

    Any help will be appreciated.
    Thanks.

  2. #2
    Join Date
    Feb 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: removing carriage return from QString

    Hi,

    Try this

    Qt Code:
    1. urlString.remove(QRegExp("[\\n\\t\\r]"));
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: removing carriage return from QString

    Or simply use QString::simplified()!

  4. The following 2 users say thank you to Lykurg for this useful post:

    gren15 (28th June 2009), kda406 (21st May 2013)

  5. #4
    Join Date
    Feb 2009
    Posts
    22
    Thanks
    4
    Qt products
    Qt3 Qt4

    Default Re: removing carriage return from QString

    Thanks for the replies!

Similar Threads

  1. Carriage Return in QString
    By incapacitant in forum Newbie
    Replies: 7
    Last Post: 2nd December 2010, 09:18
  2. error with QList with a class
    By john_god in forum Newbie
    Replies: 7
    Last Post: 12th January 2009, 21:48
  3. QTableView performances
    By miraks in forum Qt Programming
    Replies: 18
    Last Post: 1st December 2008, 10:25
  4. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.