LinuxQuestions.org A thorny problem about regular expression
 Linux - Software This forum is for Software issues. Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

 01-04-2013, 10:16 AM #1 penghcp LQ Newbie   Registered: Mar 2011 Posts: 6 Rep: A thorny problem about regular expression Hi guys: I have a thorny problem about regular expression. In my folder there are many TXTs contain datas like this: Alpha occ. eigenvalues -- -0.28771 -0.28551 -0.28076 -0.26640 -0.25753 Alpha occ. eigenvalues -- -0.24934 -0.23537 -0.20864 -0.20362 -0.18781 Alpha occ. eigenvalues -- -0.18499 Alpha virt. eigenvalues -- -0.08600 -0.07990 -0.05849 -0.05466 -0.02270 Alpha virt. eigenvalues -- -0.01590 0.00041 0.00439 0.03404 0.03475 Alpha virt. eigenvalues -- 0.04147 0.04164 0.04671 0.05375 0.06108 or Alpha occ. eigenvalues -- -0.29503 -0.29464 -0.28431 -0.27790 -0.27478 Alpha occ. eigenvalues -- -0.26611 -0.26548 -0.24146 -0.22199 -0.22060 Alpha occ. eigenvalues -- -0.22053 -0.17924 -0.17368 Alpha virt. eigenvalues -- -0.09805 -0.09012 -0.04761 -0.04677 -0.04593 Alpha virt. eigenvalues -- -0.02608 -0.00336 0.00144 0.01824 0.02201 Alpha virt. eigenvalues -- 0.03658 0.03842 0.03912 0.04273 0.04860. I need extract three values before "Alpha virt. eigenvalues"(ie: -0.20362 -0.18781 -0.18499 ) and three values after "Alpha virt. eigenvalues" (ie: -0.08600 -0.07990 -0.05849 ) PS: 1. The line numbers of lines contain "Alpha virt. eigenvalues" of these TXTs are different from each other ! 2. The "Alpha virt. eigenvalues" phrase can be find firstly in each TXT if you use the search tools. 3. There are different values after the last "Alpha occ. eigenvalues". Is there some smart methods to do this ? After all, I need dispose thousand TXTs. Thanks very much and Looking forward your replay!!!
 01-05-2013, 06:25 PM #2 haertig Senior Member   Registered: Nov 2004 Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch Posts: 2,283 Rep: Are you REQUIRING that this be done using only a regular expression (tough to impossible)? I certainly wouldn't attempt it as a pure-REGEX assignment. Or are you willing to consider a bit of scripting to help get to your end result (e.g., something written in PERL)?
 01-05-2013, 06:32 PM #3 haertig Senior Member   Registered: Nov 2004 Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch Posts: 2,283 Rep: Also, just because I have seen this type of question before - so take no offense - Is this a real world problem you are trying to solve, or a homework assignment you are looking to have someone do for you? Many here are willing to help with real world problems, but not do homework assignments. I ask simply because your request is a pretty odd one that you wouldn't often run into (sorry to have to say that), and sometimes these "odd ones" turn out to be contrived homework assignments.

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post [SOLVED] Regular Expression Problem rm_-rf_windows Linux - General 25 03-17-2012 06:22 PM [SOLVED] problem with regular expression ashok.g Programming 2 12-30-2009 07:05 AM sancho1980 Programming 10 06-08-2009 08:26 AM true_atlantis Programming 4 05-27-2009 07:35 AM raghu123 Programming 11 10-12-2008 08:17 AM

LinuxQuestions.org

All times are GMT -5. The time now is 08:54 AM.

 Contact Us - Advertising Info - Rules - Privacy - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -