section31 Posted September 16, 2004 Posted September 16, 2004 I was wondering how do forums like phpbb and others do regular expressions across several lines instead of line per line... Example, I have bbcode-like regular expressions on my scripts yet they will only work if they are on the same line as they should since these test line per line. But on forums like phpbb and others, I am able to do something like this >[b] test [/b] and it parses just fine. Does anyone know how they do something like this. Quote
borfast Posted September 26, 2004 Posted September 26, 2004 Have you tried looking at phpBB's source code? Quote
section31 Posted September 26, 2004 Author Posted September 26, 2004 Have you tried looking at phpBB's source code? hehe...I figure that would take a few hours.... I'll start tomorrow i guess. Quote
TCH-Rob Posted September 26, 2004 Posted September 26, 2004 No bumping allowed. Please read the Forum Guidelines. All posts are seen, it is rare that one gets overlooked. While we try and answer every post with at least an "I see the post but am not sure" response we dont get them all. No answer was given due to the fact that those 38 that have seen the post cannot provide anything as a solution. Quote
TCH-Rob Posted September 26, 2004 Posted September 26, 2004 OK, that is strange. I see your post and then the bump. I come back today and there is Rauls and your post above mine. Strange. In any event, no bumping and good luck on looking through all that code. Quote
mattisl Posted October 1, 2004 Posted October 1, 2004 Hi, I also needed bbCode support on one of my sites a while ago. I found the part of the phpbb code that took care of the text parsing but I was to lazy to figure out how those regular expressions work . I wrote my own function that does some search and replace actions instead, it might be a little slower but it seems to work . The functions supports: [ i ] italic [ /i ] [ b ] bold [ /b] [ u ] underline [ /u ] [ url ] links [ /u ] [ url=http://something ] hyperlinks [ /url ] [ img ] image.gif [ /img ] I attached it to this post. Hope it helps textparsing.txt Quote
section31 Posted October 27, 2004 Author Posted October 27, 2004 oh i totally forgot about this...it didn't take a few hours like i thought..more like 2 minutes...just looked at the bbcode.php file in the includes directory. Just letting u guys know that the way to do regexp across several lines is by using the s modifier. http://us2.php.net/manual/en/reference.pcr...n.modifiers.php s (PCRE_DOTALL) If this modifier is set, a dot metacharacter in the pattern matches all characters, including newlines. Without it, newlines are excluded. This modifier is equivalent to Perl's /s modifier. A negative class such as [^a]always matches a newline character, independent of the setting of this modifier. Its that simple... Quote
borfast Posted October 27, 2004 Posted October 27, 2004 Thanks, section31. Glad you figured it out Thumbs Up Quote
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.