3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = 'Blablabla Beginning Text <u>\\n\\\\*HYPERLINK \\"http://www.youtube.com/watch?v=A0VUsoeT9aM\\"1.A Youtube Video</u> blablabla Text Middle <u>\\n\\\\*HYPERLINK \\"http://www.youtube.com/watch?v=A0VUsoeT9aQ\\"2. A Youtube Video</u> blabla Text after'; $newpattern = '/(http[?.:=\w\d\\/]*)\\\\"([\s\w.]+)</'; print "does the pattern work?\n"; preg_match_all($newpattern, $string, $allMatches); var_dump($allMatches); print "yep!\n\n"; $newReplace = '<a href="\\1">\\2</a>'; var_dump( preg_replace($newpattern, $newReplace, $string) );
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
does the pattern work? array(3) { [0]=> array(2) { [0]=> string(62) "http://www.youtube.com/watch?v=A0VUsoeT9aM\"1.A Youtube Video<" [1]=> string(63) "http://www.youtube.com/watch?v=A0VUsoeT9aQ\"2. A Youtube Video<" } [1]=> array(2) { [0]=> string(42) "http://www.youtube.com/watch?v=A0VUsoeT9aM" [1]=> string(42) "http://www.youtube.com/watch?v=A0VUsoeT9aQ" } [2]=> array(2) { [0]=> string(17) "1.A Youtube Video" [1]=> string(18) "2. A Youtube Video" } } yep! string(261) "Blablabla Beginning Text <u>\n\\*HYPERLINK \"<a href="http://www.youtube.com/watch?v=A0VUsoeT9aM">1.A Youtube Video</a>/u> blablabla Text Middle <u>\n\\*HYPERLINK \"<a href="http://www.youtube.com/watch?v=A0VUsoeT9aQ">2. A Youtube Video</a>/u> blabla Text after"