is there a way to tell the occurence postition of the regex given ??

for example ..
$text = 'PHP Hypertext Preprocessor';

if (preg_match('xt', $text)){
echo 'Found Match';

Like in that example occurence position is 11.. I already know about the strpos() .. but that doesnt accept regex .. .

What im trying to do is take user input form a form and filter it ... convert everything to htmlspecialchars ... but only allow <object > </object> tags , and everything in between to stay intact .. &quot; <object width=""></object>&quot; tags...

Any help would be appreciated.

10 Years
Discussion Span
Last Post by nav33n

Cool . Thanx .. I actuially realized i didnt even need the occurence postion to do that ..
this is what i did from the i dea you gave me ..


	  $subject = '<a href="http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=35913278">Full Court Shot</a><br/><object width="430px" height="386px"><param name="wmode" value="transparent"/><param name="allowscriptaccess" value="always"/><param name="movie" value="http://lads.myspace.com/videos/vplayer.swf"/><param name="flashvars" value="culture=en-US&a=0&ap=0&y=0&m=35913278&userid=-1&showmenus=0&remove=0&t=&type=video"/><embed src="http://lads.myspace.com/videos/vplayer.swf" width="430" height="386" flashvars="culture=en-US&a=0&ap=0&y=0&m=35913278&userid=-1&showmenus=0&remove=0&t=&type=video" type="application/x-shockwave-flash" allowscriptaccess="always" /></object>';

      $pattern = '/\<object.{1,700}\<\/object\>/';

      preg_match($pattern, $subject, $matches);
      $new_data = preg_split($pattern, $subject);
//      print_r($new_data);
      $article = htmlspecialchars($new_data[0]) . "<br>\n" . $matches[0][0] . "<br>\n" . htmlspecialchars($new_data[1]);
      echo $article;

its the closest thing to perfect that i was able to think of .. Thnax

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.