Mycotheologist Posted June 30, 2012 Share Posted June 30, 2012 I need to extract some data from text files, heres the line in the text file containing the value that I need: SCF Done: E(RB3LYP) = -3540.94178466 A.U. after 20 cycles the value that I need is -3540.94178466. Heres the code I am using: if (preg_match_all('/SCF Done: E\(RB3LYP\) = (.*?)A.U./msU',$file_contents,$matches)) { $content = $matches[0][0]; } echo $content; When I echo the $content variable, heres what it outputs: SCF Done: E(RB3LYP) = -3540.94178466 A.U. How can I output the value itself, without the delimiters? In other words, I need to output just the value -3540.94178466, not the crap surrounding it. Quote Link to comment Share on other sites More sharing options...
requinix Posted June 30, 2012 Share Posted June 30, 2012 Take a look at what other information is available in $matches. Quote Link to comment Share on other sites More sharing options...
Mycotheologist Posted June 30, 2012 Author Share Posted June 30, 2012 Ah, the answer was right under my nose the whole time. $matches[1][0] contains the value without the delimiters. Thanks a lot! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.