开发者

Regular Expressions - Insert Multiple Times

Same for example I have this:

开发者_运维技巧Hello world!!
Hello all!

I want replace each "!" with a period for example. With PHP. How would I do that?


Don't you think str_replace would suffice?

$str = str_replace('!','.',$str);


preg_replace('#\!+#s', 'what_ever_you_want', $subject)


I figured out out. I cannot believe I didn't see this before. ! is a metacharacter so I need a '\' before it. That's why it wasn't working. Thanks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜