View Single Post
Old 06-28-2011, 06:00 PM  
V_RocKs
Damn Right I Kiss Ass!
 
Industry Role:
Join Date: Dec 2003
Location: Cowtown, USA
Posts: 32,406
I believe it is a problem that has more to do with where you are putting the code. I added a small piece to the code to remove the other shit at the end:

Here is the code from my example.. You can drop it into a php extension file and run it on your sever to see the output and play with it yourself...

Code:
<?

$text = '[ame="https://youtube.com/watch?v=wYJ20INbM7Q"]YouTube - &#x202a;Bill O\'Reilly Interviews Rapper Lupe Fiasco - 06/20/11&#x202c;&rlm;[/ame]';

$text3 = preg_replace('|\[ame="https://youtube.com/watch\?v=([a-z0-9]+)"\](.+)|i', '[video=youtube;$1]https://youtube.com/watch?v=$1[/video]', $text);


echo "$text <br><br>$text3";

$text5 = '[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]';
echo "<br><br>$text5";

?>
And the output is:

[ame="https://youtube.com/watch?v=wYJ20INbM7Q"]YouTube - ‪Bill O'Reilly Interviews Rapper Lupe Fiasco - 06/20/11‬‏[/ame]

[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]

[video=youtube;wYJ20INbM7Q]https://youtube.com/watch?v=wYJ20INbM7Q[/video]

Which is:

line 1 - original string
line 2 - modified string
line 3 - what you wanted.

Notice 2 and 3 match.
V_RocKs is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote