Hi folks. A while ago I was trying to put together a text processing class and was lucky enough to be graced by the assistance of the all knowing NogDog. It came in the form of a regexp that (at the time) fulfilled my requirements perfectly. My requirements on some filters however, has expanded a little and I’ve developed it a bit based on what NogDog started me with. After about a day of driving myself mad trying to isolate the problem, I’ve finally found why it keeps going wrong. The only problem is, I don’t know how to fix it.
Here’s the expression I’m having problems with:
[code]
“/b”.$linkstock[0].”b(?!(([^<]*>)|([^([{)]*(}]))|([^([{link( )?to=”([^”rn]*)”( )?is=”([^”rn]*)”}])]*([{/link}]))))/i”
And here’s a slightly more readable breakdown of it:
[code]
“/
b”.
$linkstock[0].
“b
(?!
(
([^<]*>)
|
([^([{)]*(}]))
|
(
[^
(
[{
link
( )?
to=”
([^”rn]*)
”
( )?
is=”
([^”rn]*)
”
}]
)
]
*
([{/link}])
)
)
)
/i”
The problem comes in the latter section. It is caused by these inverted sets:
[code]
([^”rn]*)
On their own, they’re fine, but the problem is, if you look a little earlier on than those sets, you’ll see that they themselves are inside an inverted set. That is where my problem lies. PHP5 says:
[quote]
Warning: preg_replace() [function.preg-replace]: Compilation failed: unmatched parentheses
I would imagine most folks that are reasonably familiar with regexp will be able to understand what I inted the express, I just don’t know how to without nesting those inverted sets. ?