RaythMistwalker Posted November 2, 2011 Share Posted November 2, 2011 I have the following code for BBCodes: $bbreplace = array ( '/(\[[bb]\])(.+)(\[\/[bb]\])/', '/(\[[ii]\])(.+)(\[\/[ii]\])/', '/(\[[uu]\])(.+)(\[\/[uu]\])/', '/(\[[ss]\])(.+)(\[\/[ss]\])/', '/(\[url=http://)(.+)(\])(.+)(\[\/url\])/', '/(\[img\])(.+)(\[\/img\])/', '/(\[img\])(.+)(\[\/IMG\])/', '/(\[color=)(.+)(\])(.+)(\[\/COLOR\])/', '/(\[color=)(.+)(\])(.+)(\[\/color\])/', '/(\[size=)(.+)(\])(.+)(\[\/SIZE\])/', '/(\[size=)(.+)(\])(.+)(\[\/size\])/', '/(\[list\])(.+)(\[\/list\])/', '/(\[list=1\])(.+)(\[\/list\])/', '/(\[list\])(.+)(\[\/LIST\])/', '/(\[list=1\])(.+)(\[\/LIST\])/', '/(\[*\])(.+)()/' ); $bbreplacements = array ( '<b>\\2</b>', '<i>\\2</i>', '<u>\\2</u>', '<s>\\2</s>', '<a href="\\2">\\4</a>', '<img src="\\2">', '<img src="\\2">', '<font color="\\2">\\4</font>', '<font color="\\2">\\4</font>', '<font size="\\2">\\4</font>', '<font size="\\2">\\4</font>', '<ul>\\2</ul>', '<ol>\\2</ol>', '<ul>\\2</ul>', '<ol>\\2</ol>', '<li>\\2</li>' ); $PostText = preg_replace($bbreplace, $bbreplacements, $PostText); Now first, Say I enter: [b]Something then this on a different line[/b] It returns: [b Something then this on a different line[/b Now if I use [list] [*]List [*]List [/list] [list=1] [*]Order [*]List [/list] It puts: [list [* List [* List [/list Order [* List [/list ] Any Ideas on this? Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted November 2, 2011 Share Posted November 2, 2011 I didn't get the same result on the first example, but there may have been a problem with greediness and the fact that dot . does not match a newline unless you use the s modifier (I also used i for case insensitivity): $bbreplace = array ( '#\[b\](.*)\[/b\]#is', ); $bbreplacements = array ( '<b>\\1</b>', ); Quote Link to comment Share on other sites More sharing options...
RaythMistwalker Posted November 2, 2011 Author Share Posted November 2, 2011 Ok Using your method the Mutli-line bold etc now works. New Code: $bbreplace = array ( '#\[b\](.*)\[\/b\]#is', '#\[i\](.*)\[\/i\]#is', '#\[u\](.*)\[\/u\]#is', '#\[s\](.*)\[\/s\]#is', '#\[url=http://(.*)\](.+)\[\/url\]#is', '#\[img\](.*)\[\/img\]#is', '#\[color=(.*)\](.*)\[\/color\]#is', '#\[size=(.*)\](.*)\[\/size\]#is', '#\[list\](.*)\[\/list\]#is', '#\[list=1\](.*)\[\/list\]#is', '#\[*\](.+)#is' ); And the replace with: $bbreplacements = array ( '<b>\\1</b>', '<i>\\1</i>', '<u>\\1</u>', '<s>\\1</s>', '<a href="\\1">\\2</a>', '<img src="\\1">', '<font color="\\1">\\2</font>', '<font size="\\1">\\2</font>', '<ul>\\1</ul>', '<ol>\\1</ol>', '<li>\\1</li>' ); Bit the list function still doesn't work. Using same as above now returns: [* List [*]List [/list] [list=1] [*]Order [*]List All as 1 list item. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted November 3, 2011 Share Posted November 3, 2011 Not tested, but try: '#\[\*\]([^\[]+)#' Quote Link to comment Share on other sites More sharing options...
RaythMistwalker Posted November 3, 2011 Author Share Posted November 3, 2011 Ok Progress being made. Repacing my one with your one now returns: List List [/ list] [ list=1] Order List Edit: spaces added to make correct ones show up. This still doesnt end first list and then start an ordered list. Quote Link to comment Share on other sites More sharing options...
RaythMistwalker Posted November 9, 2011 Author Share Posted November 9, 2011 Just like to say this still hasn't been resolved :/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.