I'm trying to use some BB code, however, i'm having a porblem when it comes to using it recursively (e.g. a quote within a quote).
It works fine if there is just one [ quote][ /quote], but if it was to look like this: [ quote][ quote][ /quote][ /quote], only the first [ quote][ /quote] gets formatted. Is there any way to make my preg_replace recursive?
Can everyone (Microsoft, LibreOffice, Euro-Office, Apple) just come together and use one standard format?
I appreciate that everyone is turning around and saying, "but our format is better! Use our format!" but it just seems a bit pointless.
I just want to read and edit a document, for goodness sake...part of the reason I try and avoid the documents that people share is because it's too much of a headache. I don't care if you use Windows, Mac or Linux, but if I can't read the damned thing because of your preference I'm going to reply saying, "I can't open that and I'm not buying a new computer to read a 2 page document."
I noticed this was already happening within my organization; my teams location will change between remote and on-site without me having to do anything. Is it possible this is live already for select customers?
While LibreOffice is not pleased to see a new competitor, they are absolutely correct in stating that Euro-Office using a MS file standard as a default is not being truly "European." Using a MS standard just means Euro-Office is just a "bastardized MS Office Suite." (Wasn't a major purpose of Euro-Office was to get away from being captive and enslaved to MS's Office Suite??)
Question
PRSBOY
Hey there,
I'm trying to use some BB code, however, i'm having a porblem when it comes to using it recursively (e.g. a quote within a quote).
It works fine if there is just one [ quote][ /quote], but if it was to look like this: [ quote][ quote][ /quote][ /quote], only the first [ quote][ /quote] gets formatted. Is there any way to make my preg_replace recursive?
Here is the code:
$input = nl2br(htmlspecialchars($input)); $input = str_replace(array('\r\n', '\r', '\n'), '<br />', $input); $find = array( "'\[b\](.*?)\[/b\]'is", "'\[i\](.*?)\[/i\]'is", "'\[quote](.+)\[/quote\]'i", ); $replace = array( "<strong>\\1</strong>", "<i>\\1</i>", "Quoting <div class=\"quote\">\\1</div>", ); $output = preg_replace($find, $replace, $input);Link to comment
https://www.neowin.net/forum/topic/779498-recursive-preg-replace/Share on other sites
12 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now