[thelist] [php] preg_replace text links?

Simon Willison cs1spw at bath.ac.uk
Mon Nov 3 11:53:47 CST 2003


kris burford wrote:
> i'm trying to get my head around some regex in php which i've lifted 
> (with only minor understanding) from "mastering regex expressions".
> 
> what i'm trying to do is scan user submitted text (parsed through 
> htmlspecialchars) pick out any links and link 'em up.

One solution is simply to not use regular expressions to solve this 
particular problem. I wrote up a blog entry on this technique (with 
sample code) a while ago:

http://simon.incutio.com/archive/2003/10/19/convertingLinks

Regular expressions are awesomely powerful, but that power often comes 
at the expense of readability and sometimes even being able to 
understand fully what your code is really doing.

-- 
Simon Willison
Web development weblog: http://simon.incutio.com/



More information about the thelist mailing list