3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string='دد'; echo preg_replace('#(?:^[^\pL]*)|(?:[^\pL]*$)#u','',$string);

preferences:
67.61 ms | 404 KiB | 5 Q