Mastodont Posted November 27, 2007 Share Posted November 27, 2007 I cannot find solution for this regexp Perl pattern: find string "ABC", followed with any character sequence except string "XYZ", and in the end would be "CAB". "ABC whatZYXever CAB" should be matched "ABC whatXYZever CAB" should be skipped Thanks for advice. Quote Link to comment Share on other sites More sharing options...
effigy Posted November 27, 2007 Share Posted November 27, 2007 Assuming "ABC" is always at the beginning: <pre> <?php $data = <<<DATA ABC whatZYXever CAB ABC whatXYZever CAB DATA; preg_match_all('/^ABC(??!XYZ).)*CAB\r?$/m', $data, $matches); print_r($matches); ?> </pre> Quote Link to comment Share on other sites More sharing options...
Mastodont Posted November 27, 2007 Author Share Posted November 27, 2007 Yessss, it works!! Many thanks, you're really genius! 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.