Results 1 to 2 of 2

Thread: QString::replace() with QRegExp capture modification

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QString::replace() with QRegExp capture modification

    Qt Code:
    1. QRegExp rx("....");
    2. rx.setMinimal(true);
    3. int s = -1;
    4. while((s = rx.indexIn(str, s+1))>=0){
    5. str.replace(s, rx.cap(0).length(), rx.cap(1).toUpper());
    6. s+= rx.cap(1).length();
    7. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to wysota for this useful post:

    Lykurg (4th March 2008)

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
  •  
Qt is a trademark of The Qt Company.