# preg\_replace vs str\_replace

**URL:** <https://forum.kirupa.com/t/preg-replace-vs-str-replace/239890>\
**Category:** programming\
**Created:** [September 26, 2007, 9:11pm UTC](https://forum.kirupa.com/t/preg-replace-vs-str-replace/239890 "2007-09-26T21:11:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 26, 2007, 9:11pm UTC](https://forum.kirupa.com/t/preg-replace-vs-str-replace/239890/1 "2007-09-26T21:11:37Z")

</div>

Just a quick question

I’m using preg\_replace at the min to replace certain words with links. i only want the first instance of that word to be replaced with a link and found that pre\_replace can do this for me with the limit. This works great.

Now i have also heard that str\_replace is faster.

Can you do the same thing with str\_replace and limit the changes to one per item or can i keep on happily using preg\_replace like i am.

Just a thought. 🙂

Cheers
