Dustin013 Posted August 6, 2009 Share Posted August 6, 2009 $re1='(Address)'; # Word 1 $re2='.*?'; # Non-greedy match on filler $re3='(Request)'; # Word 2 if ($c=preg_match_all ("/".$re1.$re2.$re3."/is", $txt, $matches)) { $word1=$matches[1][0]; $word2=$matches[2][0]; print "($word1) ($word2) \n"; } The above will output (Address) (Request). What do I do if I want to grab the filler in between those two words? Quote Link to comment Share on other sites More sharing options...
thebadbad Posted August 6, 2009 Share Posted August 6, 2009 If you enclose .*? in parentheses, $matches[2][0] will hold the filler and $matches[3][0] the second word. 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.