Is there a way , within ONE PHP regex statement , to evaluate only part of a regex selected string? Hmm.. that doesnt seem to explain what I mean very well. Lets, for example, say you had a string of text, SOME of it contained something SIMILAR to HTML tags.. "\n<ol>\n" and "\n</ol>\n", so you wanted to preg_replace for "\n\*" BUT only in the text contained between ANY occurrence of "\n<ol>\n" and "\n</ol>\n".
So far the only way I see of accomplishing this to use preg_match, a remembering array, run the sub-regex on the captured result from the preg_match, then another loop str_replacing items in the remembering array with the regexed captured result from the preg_match. Which is rather convoluted, even just to describe.
Any suggestions would be greatly appreciated.





Reply With Quote
Bookmarks