Results 1 to 6 of 6

Thread: Multiline match with QRegExp

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2007
    Posts
    89
    Qt products
    Qt4
    Platforms
    Windows
    Thanked 21 Times in 18 Posts

    Default Multiline match with QRegExp

    Hi.
    I'm having some trouble using QRegExp to match a multiline expression. Actually I'm trying to write a Markdown syntax highlighter, and I'd like to recognize something like:

    Qt Code:
    1. Heading 1
    2. ===========
    3.  
    4. Heading 2
    5. -----------
    To copy to clipboard, switch view to plain text mode 

    I tried ".+\\n=+" and similar, with no success.


    EDIT:
    I made some attempts with the RegExp example, and I found out I should be able to use "[^\\n][\\w\\s][^\\n]+\\n=+".
    The problem is that QSyntaxHighlighter::highlightBlock() is called once per line, so I can't match anything which spans more than one line. Documentation suggests using a state based highlighter, but I don't think it would work since I know if a line is an heading only when I read the next line.

    Any idea how to do that (except using alternative syntax for headings off course)?
    Last edited by bender86; 3rd March 2011 at 12:07.

Similar Threads

  1. Multiline entry in a QMenu
    By tyrdal in forum Qt Programming
    Replies: 0
    Last Post: 28th September 2009, 11:54
  2. Replies: 1
    Last Post: 21st September 2009, 07:30
  3. Multiline QCombobox
    By tyrdal in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2009, 18:37
  4. Multiline QPushButton
    By uestebanez in forum Qt Programming
    Replies: 4
    Last Post: 12th October 2008, 21:25
  5. QRegExp match all excpet "_"
    By mattia in forum Newbie
    Replies: 6
    Last Post: 28th March 2008, 12:53

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.