Well okay, we know that preg_replace() replaces from the start of the string, to the end.
Is it possible to reverse this - ie get it to start replacing from end to start?
If you want a more solid example, this would help with nested bbCodes, for example, if we wanted to remove quotes from a message:
Using a simple preg_replace() in the above, and replacing with a blank string would obviously cause issues, since it would match the first [quote] with the first [/quote] (assuming we use the "?" modifier; if we don't the first [quote] would match with the last [/quote] which of course, is also problematic).
If the nature could be reversed (short of having to write a custom function), it would actually work...
Possible?
Is it possible to reverse this - ie get it to start replacing from end to start?
If you want a more solid example, this would help with nested bbCodes, for example, if we wanted to remove quotes from a message:
[quote]
test
[quote]inside quote2[/quote]
[/quote]
random text
[quote]Another quote[/quote]
Using a simple preg_replace() in the above, and replacing with a blank string would obviously cause issues, since it would match the first [quote] with the first [/quote] (assuming we use the "?" modifier; if we don't the first [quote] would match with the last [/quote] which of course, is also problematic).
If the nature could be reversed (short of having to write a custom function), it would actually work...
Possible?