Results 1 to 10 of 10

Thread: QRegExp independent subexpressions

  1. #1
    Join Date
    Apr 2010
    Location
    Switzerland
    Posts
    16
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QRegExp problem

    this "(?<=exp)" dose not work with QRegExp:

    e.g.
    Qt Code:
    1. QRegExp rx("((?<=a)b)");
    2. rx.indexIn("cx ab ab xv");
    3. QStringList list = rx.capturedTexts();
    To copy to clipboard, switch view to plain text mode 

    after executing that code, "list" is empty which is wrong.

    any idea?

  2. #2
    Join Date
    Apr 2010
    Location
    Switzerland
    Posts
    16
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QRegExp problem

    anyone??
    this problem is really bugging me.. still couldn't find out why QT dosent recognize "(?<=exp)"

  3. #3
    Join Date
    Apr 2010
    Location
    Switzerland
    Posts
    16
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QRegExp problem

    someone delete this thread from here.. I'm posting it in "Qt Programming" sub-forum

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QRegExp problem

    No, you are posting here because the answer to your question is in the documentation.

  5. #5
    Join Date
    Apr 2010
    Location
    Switzerland
    Posts
    16
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QRegExp problem

    Quote Originally Posted by wysota View Post
    No, you are posting here because the answer to your question is in the documentation.
    from qt docs: ""independent" subexpressions and conditional expressions are not supported."
    ok I'm starting new thread..

  6. #6
    Join Date
    Apr 2010
    Location
    Switzerland
    Posts
    16
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QRegExp independent subexpressions

    since QT dose not support "independent" subexpressions in regular expression like : "(?<=exp)"
    so are there any ways around it?

    e.g:
    Qt Code:
    1. QRegExp rx("((?<=a)b)");
    2. rx.indexIn("cx ab ab xv");
    3. QStringList list = rx.capturedTexts();
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QRegExp independent subexpressions

    What is the exact effect you wish to obtain?

    Also, please don't spawn multiple threads on the same or similar subject. Instead continue the old thread. Threads merged.

  8. #8
    Join Date
    Apr 2010
    Location
    Switzerland
    Posts
    16
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QRegExp independent subexpressions

    Quote Originally Posted by wysota View Post
    What is the exact effect you wish to obtain?

    Also, please don't spawn multiple threads on the same or similar subject. Instead continue the old thread. Threads merged.
    alright..
    the thing is that:
    suppose we have this string:
    "blablabla : 234 : 23k 5j245 :345"
    I need to get this list: "234", " 23k 5j245", "345"
    (or we can say all words between ":" should be separated and last word may not end with ":")
    this regular expression works fine: (?<=:\s*)[^:]*(?=(:| ))

    so how do I not use "(?<=exp)" there?

  9. #9
    Join Date
    Apr 2010
    Location
    Switzerland
    Posts
    16
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QRegExp independent subexpressions

    nvm..
    solved by using these two regular expression together:
    :[^:]*(?=(:| )) and then applying to each capture with [^: ].*$

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QRegExp independent subexpressions

    Hmm... wouldn't this be simpler?

    Qt Code:
    1. QString myWeirdString = "...";
    2. QStringList components = myWeirdString.split(":"); // or QRegExp("\s*:\s*") if you want to ignore white spaces
    To copy to clipboard, switch view to plain text mode 

  11. The following user says thank you to wysota for this useful post:

    Nik8768 (20th April 2010)

Similar Threads

  1. Scale independent QGraphicsItem
    By Twoslick in forum Qt Programming
    Replies: 3
    Last Post: 24th March 2010, 06:59
  2. Platform independent GUI
    By bnilsson in forum Qt Programming
    Replies: 39
    Last Post: 28th November 2009, 12:00
  3. Independent Right-Click Menus
    By HiFly in forum Qt Programming
    Replies: 5
    Last Post: 20th February 2009, 08:58
  4. Replies: 3
    Last Post: 4th February 2008, 20:28
  5. system-independent C++ data types
    By magland in forum General Programming
    Replies: 15
    Last Post: 28th March 2007, 21:33

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.