cotonti.com : preg_replace questions https://www.cotonti.com Son konu mesajları Cotonti en Mon, 13 Oct 2025 21:42:39 -0000 fade2k Thank you & Thanks for the link!

Your probably right about the @ sign -- Got use to a pesky !bot =0D

I'm slowly getting ahang of this stuff =0)

]]>
Sal, 19 Haz 2012 21:56:55 -0000
GHengeveld I think what you're looking for is something like this:

$var = preg_replace('/!([^\s])/', '<a href="https://www.cotonti.com/index.php?e=users&m=details&u=$1">$1</a>', $var);

A helpful tool to check your regular expressions is here: http://gskinner.com/RegExr/

By the way, don't you think the @ sign is more appropriate (considering Twitter's usage of this).

]]>
Pzt, 18 Haz 2012 20:59:18 -0000
fade2k I'm my oddball quest to learn PHP, I've been working on simple applications (what better way to learn right?). So I find myself using preg_replace to convert usernames into links in posts using preg_replace. My hangup so far has been the whole regex .. I get it .. sort-of.

$var = preg_replace('/[!]+('.$value.')/',$shoutLink,$var); // $var = a post

The shoutlink is just a link to the members profile. Anyway, it works if the !username is on the first line of the input but when there are new lines without a space afterwords and another !username -- both fail to be replaced with the link. What gives? Does preg_replace see new lines as part of the input (\n!username) or does it ignore it?

LoL thanks ahead of time.

]]>
Pzt, 18 Haz 2012 15:56:40 -0000