3v4l.org

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

preferences:
27.64 ms | 404 KiB | 5 Q