Results 1 to 12 of 12

Thread: Does QRegExp::lastIndexIn work correct?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    7
    Qt products
    Qt4

    Default Re: Does QRegExp::lastIndexIn work correct?

    OK. Any suggestion about backward capturing using QRegExp? In my example I want get "_1234_" from position 5.

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Does QRegExp::lastIndexIn work correct?

    What exactly do you want to capture?

  3. #3
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Does QRegExp::lastIndexIn work correct?

    Exactly explain what you are try to do (not how you are trying to achieve that).
    I have gut feeling that you just need something like that (especially that your regular excretion is just a wild card):
    Qt Code:
    1. QStringList items = str.split("_", QString::SkipEmptyParts);
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    7
    Qt products
    Qt4

    Default Re: Does QRegExp::lastIndexIn work correct?

    An example, a cursor in texteditor is inside the keyword:

    Qt Code:
    1. blablabla get-deffunct|ion-list blalblabla (| <- cursor)
    To copy to clipboard, switch view to plain text mode 

    and I want detect is the word correct (get-deffunction-list) or not, if it is correct I need capture it.

    It was a good idea for use reg expression for capturing left part and if it was correct get right part of word.

    Searching word boundary (space, tabs etc) not a good idea, becouse:

    Qt Code:
    1. bla blablabla>=get-deffunction-list!=blalblabla bla
    To copy to clipboard, switch view to plain text mode 

    is correct to.
    Last edited by Nebelig; 20th June 2011 at 14:25.

  5. #5
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Does QRegExp::lastIndexIn work correct?

    1. if you have editor then you should use QTextDocument::find-4
    2. in regular expression there is assertion "\b" which means word boundary (you don't have to use space or other character to detect that), see QRegExp documentation.
    example: QRegExp("\\b\\w+\\b");
    3. check qt examples there is something similar to your problem.

  6. #6
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    7
    Qt products
    Qt4

    Default Re: Does QRegExp::lastIndexIn work correct?

    MarekR22, thanks for the advice.

Similar Threads

  1. Is this sentence correct?
    By SWEngineer in forum Newbie
    Replies: 6
    Last Post: 21st June 2011, 01:56
  2. Replies: 1
    Last Post: 10th March 2010, 18:19
  3. QRegExp doesn't seem to work as it should
    By thomaspu in forum Qt Programming
    Replies: 3
    Last Post: 21st December 2007, 07:49
  4. how to integrate qt into kdevelop correct way
    By amit_pansuria in forum KDE Forum
    Replies: 1
    Last Post: 25th November 2006, 08:58
  5. QSetting value() not correct
    By bpetty in forum Newbie
    Replies: 1
    Last Post: 14th August 2006, 19:58

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.