Jump to content
Craig Hopson

str_replace with regex

Recommended Posts

You're simply using the wrong function. Use preg_replace() instead. str_replace() only replaces one literal string with another.

  • Like 1

Share this post


Link to post
Share on other sites

Well, one problem may be that your string doesn't start with "~&". Also, the expression is telling the interpretter to replace the entire string with a single asterisk.

Share this post


Link to post
Share on other sites

Still cant get this code to work i have broken it back to basics still giving error

$test = "http://seekface.com/themes/blue/ico.gif";$URL = "www.seekface.com";echo preg_replace($URL," ",$test);

Share this post


Link to post
Share on other sites

That's because the expression doesn't match anything in the string. Also, the "." character has a meaning in regular expressions, and your expression is missing delimiters.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...