Results 1 to 1 of 1

Thread: CaptureText of on "AND operation" Regular Express

  1. #1

    Default CaptureText of on "AND operation" Regular Express

    Hi,

    I am using QRegExp to perform "AND" operation on the QString. I would like to get the position on found QString but always get 0.

    I use positive lookahead to perform "AND" operation

    QRegExp keyword_regexp("(?=.*cat)(?=.*dog)");
    keyword_regexp.setPatternSyntax(QRegExp::RegExp);
    QString document_text = "rooster, cat, dog, cow, cat and chicken";

    int found_index = document_text.indexOf(keyword_regexp);
    while (found_index >= 0)
    {
    int length = keyword_regexp.matchedLength();
    /*do something on the length and found_index*/
    found_index = document_text.indexOf(keyword_regexp, found_index + length);
    }

    I receive infinity loop at document_text due to indexOf(keyword_regexp); always return me 0. Provided that matchedLength() return 0 too.

    It is successful if i set my keyword_regexp to "cat" only. But not an Positive lookahead ?=

    I am not going to use OR operation (cat|dog) because i just only want both keywords to exist and proceed on my function.

    Any advise on this?
    Last edited by alancupid; 23rd April 2012 at 08:05.

Similar Threads

  1. Replies: 6
    Last Post: 12th September 2011, 13:23
  2. Replies: 3
    Last Post: 15th February 2010, 18:27
  3. Replies: 3
    Last Post: 8th July 2008, 20:37
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 20:05
  5. QFile Problem~ "Unknow error" in "open(QIODevice::ReadWrite)"
    By fengtian.we in forum Qt Programming
    Replies: 3
    Last Post: 23rd May 2007, 16: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
  •  
Qt is a trademark of The Qt Company.