Results 1 to 2 of 2

Thread: Method replace with Qregxp

  1. #1
    Join Date
    Jun 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Method replace with Qregxp

    Hello everybody,
    I have a QString object,and i want to replace slash,backslash and spaces to underscore character.
    How can i do it with the method replace with qregxp

    Thank you


    Added after 35 minutes:


    I found the solution of my problem.
    Qt Code:
    1. myQString.replace(QRegExp("[\\\\/ ]"), QString("_"));
    To copy to clipboard, switch view to plain text mode 

    Thank you
    Last edited by mdjigo; 24th June 2011 at 16:27.

  2. #2
    Join Date
    Mar 2011
    Location
    Russia, Lipetsk
    Posts
    17
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Method replace with Qregxp

    If I understand You, try some construction:

    Qt Code:
    1. s.replace (QRegExp("^*[\\/ ]*"), "_");
    To copy to clipboard, switch view to plain text mode 

    I may be wrong in the regular expression.

Similar Threads

  1. Calling a method from a non-member method
    By AndresBarbaRoja in forum Newbie
    Replies: 5
    Last Post: 19th March 2011, 10:38
  2. Replies: 1
    Last Post: 25th November 2010, 11:37
  3. Replace keyPressEvent (dot with tab)
    By the_bis in forum Qt Programming
    Replies: 1
    Last Post: 6th June 2008, 10:43
  4. How do I replace a widget?
    By pir in forum Qt Programming
    Replies: 4
    Last Post: 24th July 2006, 16:51
  5. Replace text
    By Hz in forum Qt Programming
    Replies: 2
    Last Post: 22nd March 2006, 08:16

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.