PHP Regex Question

Posted by oyerli on Stack Overflow See other posts from Stack Overflow or by oyerli
Published on 2010-05-13T17:31:31Z Indexed on 2010/05/13 17:34 UTC
Read the original article Hit count: 224

Filed under:
|

Hi,

I am developing an application using PHP but I am new to regular expressions, I could not find a solution to my problem. I want to replace all occurences of #word with a link, i have written a preg_match for this:

$text=preg_replace('~#([\p{L}|\p{N}]+)~u', '<a href="/?aranan=$1">#$1</a>', $text);

The problem is, this regular expression also matches the html character codes like

&#039;

and gives corrupt output. I need to exclude the words starting with &# but i do not know how to do that using regular expressions.

Thanks for your help.

© Stack Overflow or respective owner

Related posts about php

Related posts about regex