3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ '<p>test:</p>', '<p>test: foo</p>', '<p>foo:</p>', '<p>: foo</p>', '<p>test </p><p>:</p>', ]; foreach ($input as $val) { echo(preg_replace('/(<p>)([^<]+?:)(.*)/', '$1<strong>$2</strong>$3', $val)); echo("\n"); }

preferences:
61.3 ms | 402 KiB | 5 Q