Delimiter must not be alphanumeric

Hi all I get this error:

Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /html/try.php on line 3

with this code- what delimiter is it refering to? Thanks

$bot = preg_match('Yahoobot', $ua);
function dynlink($url, $inner) {
if($bot==0) {
echo '<a href="' . $url .'">' . $inner . '</a>';
else { echo $inner; }

<?php dynlink('/contactus.html','Contact Us') ?>

The regular expression needs to be contained within forward slashes. See the preg_match documentation for examples.

And of course, you should be aware that the technique you’re using is likely to put you in the deep doo-doo. You can instead use nofollow on untrusted links to prevent all well-behaved spiders from following them.

See also: Delimiters in the PCRE regex section of the PHP manual.

As shown in the article Salathe linked to, you don’t have to use a forward slash as the delimiter.

I usually use forward slashes, but if the expression itself contains a slash I use the wiggly dash: ~

This is useful for URLs. An example match:

if(preg_match('/^http:\\\\/\\\\/www\\.([A-Za-z0-9_])\\.com\\\\/?$/', $Url)){

Could be made easier by using a different delimiter, so the slash doesn’t have to be escaped:

if(preg_match('~^http://www\\.([A-Za-z0-9_])\\.com/?$~', $Url)){
Off Topic:

Note the above probably isn’t a valid URL match, it was an example :wink:

Thanks for all the answers I will incorporate the answers in my code.

Paul nofollow doesn’t work anymore unfortunately for google pagerank sculpting so this is why I am using this solution.

More SEO rumours? :rolleyes:

No not rumours. No follow is not advised for page rank sculpting anymore according to the person who invented page rank sculpting. Thanks.