Results 1 to 3 of 3

Thread: Finding LFs with QRegExp

  1. #1
    Join Date
    Oct 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Finding LFs with QRegExp

    Hi all,

    I need to implement a "Find" menu as usual (press Ctrl+F ), using QRegExp.
    Its easy, also highlighting matches, but I have a (newbie) little problem with LF character. I think I am missing something, for example:

    Text to find:
    Qt Code:
    1. Version S98135-B Linked on
    2. >> >>
    3. >>
    4. >>
    5. ...
    To copy to clipboard, switch view to plain text mode 

    If I look for an expression as "\t>>", QRegExp finds a tabulator and two extra chars (>>) as requested, but if I look for "\n>>" QRegExp doest not found nothing and returns FALSE. Also, these expressions fails:
    "\\n"
    "\x000A"
    "\x000D\x000A"
    "\r\n"
    (I know, all of them are the same, and due to this is a Unix system, CRLF has no sense).

    What am I doing wrong?

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    1
    Thanked 94 Times in 86 Posts

    Default Re: Finding LFs with QRegExp

    In general, REs don't span multiple lines. You should reformulate your matching parameters to accomodate this and search only on a single line. There is no difference between a psuedo-string that 'ends' with '\n>>' and an actual string that begins with '>>', which is easily matched with '^>>'.

  3. #3
    Join Date
    Oct 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: Finding LFs with QRegExp

    Newbie for Qt and Regexps

    Thanks for your reply

Similar Threads

  1. Finding a QWidget from a screen XY
    By andyp in forum Qt Programming
    Replies: 5
    Last Post: 26th August 2012, 10:15
  2. Finding Files
    By arbi in forum Qt Programming
    Replies: 4
    Last Post: 21st August 2009, 15:30
  3. Finding the 'current' dialog
    By zarkzervo in forum Qt Programming
    Replies: 7
    Last Post: 24th April 2009, 09:20
  4. Finding widget by name
    By mkarakaplan in forum Newbie
    Replies: 1
    Last Post: 9th December 2007, 18:38

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.