sup Posted July 5, 2010 Share Posted July 5, 2010 I have the following lines in an array Sten1986 folds Denis2391 folds hesims raises to $1 Raphaln123 folds Southlander calls $0.90 d3dsheep raises to $3.75 I want to extract their action. So it's either call , fold, or raise So I made this: /d3dsheep (.*?) / This returns me 'raises', which is perfect. But when some1 folds, there is no Space at the end, so dont get the Fold actions. Can some1 tell me what to change about my regex to get FOLDS and Raises/calls? Quote Link to comment Share on other sites More sharing options...
premiso Posted July 5, 2010 Share Posted July 5, 2010 For something this simple, explode would be a better choice. $exploded = explode(" ", $input); $action = $exploded[1]; Should get you what you need. Quote Link to comment Share on other sites More sharing options...
sasa Posted July 5, 2010 Share Posted July 5, 2010 try <?php $test = 'Sten1986 folds Denis2391 folds hesims raises to $1 Raphaln123 folds Southlander calls $0.90 d3dsheep raises to $3.75'; preg_match('/Southlander (folds|raises|calls)/', $test, $out); print_r($out[1]); ?> 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.