3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'start ** not bold ** and **bold** not bold **bold *** still bold** not bold **** not bold ****'; echo preg_replace('/(?<!\*)\*\*(?![\s*])(.*?)(?<![\s*])\*\*(?!\*)/', '<b>$1</b>', $string);

preferences:
25.63 ms | 404 KiB | 5 Q