Results 1 to 10 of 10

Thread: QString find Whole word Only

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows
    Thanks
    9
    Thanked 27 Times in 27 Posts

    Default Re: QString find Whole word Only

    hm..i think that bcteh_98 will be confused after read answers
    a life without programming is like an empty bottle

  2. #2
    Join Date
    Jan 2006
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QString find Whole word Only

    Thank it work fine. But I still have a small problem.

    regexp = \bOK\b

    "I am OK_Now" Index of Match -1 ok fine
    "I am (OK) Now" Index of Match 7 ok fine
    "I am OK@Now" Index of Match 5 ok fine
    =================================
    "I am NOT-OK Now" Index of Match 9
    "I am OK-Now" Index of Match 5
    I don't want the last two result to match,
    how to write a regular expressions to make it not Match -1.

    Regards
    Teh

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QString find Whole word Only

    Use a regexp of "[ \t\n]OK[ \t\n]". Or: "[^ \t\n]+" which will match a sequence of characters not containing a space, tab or newline in general.

Similar Threads

  1. QString - no member function called 'find'
    By pitterb in forum Newbie
    Replies: 1
    Last Post: 13th January 2009, 11:31
  2. How to fhind whole word only in QString
    By sawerset in forum Qt Programming
    Replies: 2
    Last Post: 12th December 2008, 05:18
  3. problems installing Qt opensource with msvc2008 support
    By odin1985 in forum Installation and Deployment
    Replies: 6
    Last Post: 24th May 2008, 09:06
  4. Replies: 11
    Last Post: 11th October 2007, 16:34
  5. 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
  •  
Qt is a trademark of The Qt Company.