Results 1 to 14 of 14

Thread: Regular expression help neede

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2011
    Posts
    160
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    31

    Default Regular expression help neede

    I have collection of files, the contents of all those files have the following format

    Qt Code:
    1. -- File name
    2. --
    3. -- listOne (L1)
    4. -- listTwo (L2)
    5. -- listThree (L3)
    6. -- HeaderLine (HE)
    7. -- listFour (L6)
    8. -- listFive (L2)
    9. -- listSix (L9)
    10. -- listSeven (L0)
    11. -- someline (SL)
    12. -- listeight (LL)
    13. --
    14. --
    15. REMAINING CONTENTS OF THE LINE
    16. -----------------------------------------------------------------------
    17. some more contents
    18. ------------------------------------------------------------------------
    To copy to clipboard, switch view to plain text mode 

    Here i want to store only L1,L2,L3 etc in a list, except HE,SL and remaining lines of files
    How can i do that?
    Please help me, i went through QREgExp class defination also, and i wrote code but that seems to be very big and inserts some blank strings into stored list


    Qt Code:
    1. while(!f.atEnd() && (!line.contains("------------------------------------------")))
    2. {
    3.  
    4. if(!line.contains("-- "))
    5. {
    6. flag=1;
    7. QRegExp rx("[\(]([a-z]|[0-9]|[_]|[A-Z])+[\)]");
    8. rx.indexIn(line);
    9. QRegExp rx1("([a-z]|[0-9]|[_]|[A-Z])+");
    10. rx1.indexIn(rx.cap(0));
    11. captured.append(rx1.cap(0));
    12. line=f.readLine();
    13. }
    14. else if(flag==1)
    15. {
    16. flag++;
    17. captured.pop_back();
    18. QRegExp rx("[\(]([a-z]|[0-9]|[_]|[A-Z])+[\)]");
    19. rx.indexIn(line);
    20. QRegExp rx1("([a-z]|[0-9]|[_]|[A-Z])+");
    21. rx1.indexIn(rx.cap(0));
    22. captured.append(rx1.cap(0));
    23. line=f.readLine();
    24. }
    25.  
    26. else if(flag>0)
    27. { flag++;
    28. QRegExp rx("[\(]([a-z]|[0-9]|[_]|[A-Z])+[\)]");
    29. rx.indexIn(line);
    30. QRegExp rx1("([a-z]|[0-9]|[_]|[A-Z])+");
    31. rx1.indexIn(rx.cap(0));
    32.  
    33.  
    34. captured.append(rx1.cap(0));
    35. line=f.readLine();
    36. }
    37.  
    38. }
    To copy to clipboard, switch view to plain text mode 


    Please help me sort this problem
    Last edited by aurora; 13th January 2012 at 11:45.

Similar Threads

  1. Regular expression
    By QFreeCamellia in forum Newbie
    Replies: 8
    Last Post: 30th December 2011, 22:34
  2. Regular expression help!
    By ConkerX in forum Qt Programming
    Replies: 10
    Last Post: 31st August 2011, 15:47
  3. Help with regular expression
    By Gourmet in forum General Programming
    Replies: 19
    Last Post: 11th August 2011, 15:04
  4. Regular Expression Problem
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2009, 09:41
  5. set a regular expression on QTextEdit
    By mattia in forum Newbie
    Replies: 3
    Last Post: 27th March 2008, 10:16

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.