Matching URLs *not* inside [code] tags
Posted: Sun Nov 15, 2009 3:15 pm
In my script, URLs are automatically parsed into Anchored HTML links. I also have a [ code ] (I call it [raw] -- as in raw-text) that obviously used for when you don't want text to formatted. The problem is that URLs inside [raw] tags get automatically hyper-linked.
So, how would I match URLs not inside [ code ] tags?
I tried this (and other several modifications):
But it doesn't work.. at all.
I use [^(\&\#91;raw\])] instead of [^(\[raw\])] because I replace the opening-square bracket with it's corresponding entity to prevent it from being matched later on by my other Regex.
A preemptive thanks for your time.
So, how would I match URLs not inside [ code ] tags?
I tried this (and other several modifications):
Code: Select all
'/[^(\&\#91;raw\])] ((mailto:|(http|ftp|nntp|news):\/\/).*?)(\s|<|\)|"|\\\\|\'|$) [^(\&\#91;\/raw\])]/si'I use [^(\&\#91;raw\])] instead of [^(\[raw\])] because I replace the opening-square bracket with it's corresponding entity to prevent it from being matched later on by my other Regex.
A preemptive thanks for your time.