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. Link to comment https://forums.phpfreaks.com/topic/79137-solved-all-except-some-string/ 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> Link to comment https://forums.phpfreaks.com/topic/79137-solved-all-except-some-string/#findComment-400559 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! Link to comment https://forums.phpfreaks.com/topic/79137-solved-all-except-some-string/#findComment-400627 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.