Convert uppercase matches to bold using regex

后端 未结 2 721
忘掉有多难
忘掉有多难 2021-01-21 23:07

i need to find all uppercase words in a string and set it bold

$_POST[\'descricao\'] = \"UPPERCASE test WORD\"
$_POST[\'descricao\'] = preg_replace(\"\\b[A-Z]{2,         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-22 00:04

    Use this:

    $_POST['descricao'] = "UPPERCASE test WORD"
    $_POST['descricao'] = preg_replace("/\b([A-Z]{2,})\b/", "$1", $_POST['descricao']);
    

提交回复
热议问题