Jump to content

How would you? Regex...


Dustin013

Recommended Posts

  
$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?

Link to comment
https://forums.phpfreaks.com/topic/169118-how-would-you-regex/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.