Results 1 to 3 of 3

Thread: Regular Expression to match Parenthesis ( {} ), Brackets ( (),[] )

  1. #1
    Join Date
    Nov 2013
    Posts
    11
    Qt products
    Qt5

    Default Regular Expression to match Parenthesis ( {} ), Brackets ( (),[] )

    Please someone provide me code for matching parenthesis and Brackets using regular expressions.

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Regular Expression to match Parenthesis ( {} ), Brackets ( (),[] )

    Is this some kind of school assignment ? There is another thread about this here : link .

  3. #3
    Join Date
    Nov 2013
    Posts
    11
    Qt products
    Qt5

    Default Re: Regular Expression to match Parenthesis ( {} ), Brackets ( (),[] )

    I had tried these codes but they are not working..

    functionFormat1.setFontItalic(false);
    functionFormat1.setForeground(Qt::green);
    rule.pattern = QRegExp("[([^\]]+)]");
    rule.format = functionFormat1;
    highlightingRules.append(rule);

    functionFormat1.setFontItalic(false);
    functionFormat1.setForeground(Qt::green);
    rule.pattern = QRegExp("\\b{([^}]+)}");
    rule.format = functionFormat1;
    highlightingRules.append(rule);

    functionFormat1.setFontItalic(false);
    functionFormat1.setForeground(Qt::green);
    rule.pattern = QRegExp("\\b{[^}]*}");
    rule.pattern = QRegExp("\\(([^)]+)\)");
    rule.format = functionFormat1;
    highlightingRules.append(rule);

    and i tried this one also for parenthesis , but this again not working :

    rule.pattern = QRegExp("\\b{[^}]*}");

Similar Threads

  1. Regular expression
    By aguleo in forum Newbie
    Replies: 0
    Last Post: 25th January 2013, 15:00
  2. Regular expression
    By QFreeCamellia in forum Newbie
    Replies: 8
    Last Post: 30th December 2011, 22:34
  3. Regular expression help!
    By ConkerX in forum Qt Programming
    Replies: 10
    Last Post: 31st August 2011, 15:47
  4. Help with regular expression
    By Gourmet in forum General Programming
    Replies: 19
    Last Post: 11th August 2011, 15:04
  5. Regular expression in QLineEdit?
    By vishal.chauhan in forum Qt Programming
    Replies: 3
    Last Post: 1st October 2007, 10:58

Tags for this Thread

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.