The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

preg_replace error

Can someone tell me why I would be getting a preg_replace error with this borrowed code?

I have a web page that is set as charset=utf-8; dbase is set the same way (using general). Information that comes from the dbase table has web URLs on it and this function is suppose to replace any text with 'http://' or 'www.' as a link address. I've tried to contact the creator, but no answer.

$s = 'Here is a text - www.ellehauge.net - it has some links with e.g. comma, www.one.com,in it. Some links look like this: http://mail.google.com - mostly they end with aspace or carriage return www.unis.no<br /> - but they may also end with a period: http://ellehauge.net. You may even putthe links in brackets (www.skred-svalbard.no) (http://one.com).From time to time, links use a secure protocol like https://gmail.com |This.one.is.a.trick. Sub-domaines: http://test.ellehauge.net |www.test.ellehauge.net | Files: www.unis.no/photo.jpg |Vars: www.unis.no?one=1&amp;~two=2 | No.: www.unis2_check.no/doc_under_score.php |www3.one.com | another tricky one:http://ellehauge.net/cv_by_id.php?id%5B%5D=105&amp;id%5B%5D=6&amp;id%5B%5D=100';

You are using a non-ASCII character as the delimiter (the broken bar character ¦). Change it to some non-alphanumeric (nor backslash) printable ASCII character which doesn't already exist in the pattern (unescaped): your best bet would be the backtick (`) character.

My web page is set for 'iso...', the database was set to 'latin...', but my insert forms charset was not set up correctly when it posted the information. I ran some experiments and found that out. WHEW!

Now, regarding your response Salathe, I would've never thought that that would become an issue. Thanks for the suggestion. Maybe I should run another experiment...