How can I get at the matches when using preg_replace in PHP?

前端 未结 4 2068
醉话见心
醉话见心 2020-12-08 18:05

I am trying to grab the capital letters of a couple of words and wrap them in span tags. I am using preg_replace for extract and wrapping purposes, but it\'s not outputting

4条回答
  •  悲&欢浪女
    2020-12-08 18:58

    You need to put the pattern in parentheses /([A-Z])/, like this:

    preg_replace("/([A-Z])/", "$1", $str)
    

提交回复
热议问题