实际上,我正试图找到一种方式来获得像#34; GEWO"走出" Get Word"通过使用preg_replace函数。事情就是可以有一个像" Get"或"获取Word和另一个Word"所以我必须分别得到正确的字符串。
谢谢!
答案 0 :(得分:1)
你可以不使用REGEX这样做:
$str = 'Get Word';
$arr = explode(" ", $str);
foreach($arr as $word){
$newstr .= strtoupper(substr($word, 0, 2));
}
echo $newstr;
//=> GEWO
答案 1 :(得分:0)
使用此:
123.456,79 €
输出:$s = "Get Word And another Word";
$s = preg_replace('/(?<=\w{2})\w*\b(\s|$)/','',$s);
$s = strtoupper($s);
echo $s;