Jump to content

str_replace or ... ?


ibzi

Recommended Posts

Let's say I have a paragraph of text.


"This forum is phpfreaks.com and the person posting this message goes by the Username of ibzi. This is just a paragraph to show an example to the fellow helpers."

Now lets say I want to replace all the occurence of the word "and" regardless about the case. It can be And or AND or aND etc.

How would i do this? I want to replace it with something like:

and >>>>>> <a target="_blank" href="search.php?q=and">and</a>

I tried preg_match but I dont know how to use the function, i constantly get wrong result near the "_blank".

Please help.. it will be appreciated.
Link to comment
Share on other sites

[!--quoteo(post=352692:date=Mar 7 2006, 06:24 PM:name=ibzi)--][div class=\'quotetop\']QUOTE(ibzi @ Mar 7 2006, 06:24 PM) [snapback]352692[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Let's say I have a paragraph of text.
"This forum is phpfreaks.com and the person posting this message goes by the Username of ibzi. This is just a paragraph to show an example to the fellow helpers."

Now lets say I want to replace all the occurence of the word "and" regardless about the case. It can be And or AND or aND etc.

How would i do this? I want to replace it with something like:

and >>>>>> <a target="_blank" href="search.php?q=and">and</a>

I tried preg_match but I dont know how to use the function, i constantly get wrong result near the "_blank".

Please help.. it will be appreciated.
[/quote]

You definately want regular expressions. Try preg_replace though. There are plenty of regular expression generators to help you get it just right.
Link to comment
Share on other sites

[!--quoteo(post=352734:date=Mar 7 2006, 10:48 PM:name=greycap)--][div class=\'quotetop\']QUOTE(greycap @ Mar 7 2006, 10:48 PM) [snapback]352734[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You definately want regular expressions. Try preg_replace though. There are plenty of regular expression generators to help you get it just right.
[/quote]

I've been looking for generators for quite awihle now. Any chance anyone can point me to a direction?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.