<?php $data = 'foo_bar_p'; echo preg_replace('/^[\pZ\p{Cc}]+|[\pZ\p{Cc}]+$/u', '', $data);
You have javascript disabled. You will not be able to edit any code.