0
$str="&%*&^h-e_l_lo*&^*&";

に分割する方法

$left="&%*&^";//until the first A-Za-z character
$right="*&^*&";//right after the last A-Za-z character
$middle = "h-e_l_lo";

$left を見つけるためにこの方法を見つけましたが、それが最善の方法であるとは思えません。

$curr_word = "&%*&^h-e_l_lo*&^*&";
preg_match('~[a-z]~i', $curr_word, $match, PREG_OFFSET_CAPTURE);
$left = substr($curr_word, 0,$match[0][1]);// &%*&^
4

1 に答える 1