bbcode

REGEX for bbcode links + non-bbcode URLs

本秂侑毒 提交于 2020-01-07 04:05:13
问题 Tehre doesn't appear to be a clear answer on how to do this the best way. I have some bbcode which may have links in bbcode format: [url=http://thisisalink.com]link[/url] as well as possible copy/pasted urls: http://thisisalink.com I want to replace both instances with a clickable link. I currently have the following: regexs running: "/\[link=http:\/\/(.*?)\](.*?)\[\/link\]/is" "/\[link=https:\/\/(.*?)\](.*?)\[\/link\]/is" "/\[link=(.*?)\](.*?)\[\/link\]/is" $URLRegex = '/(?:(?<!(\[\/link\]|\

scrub document of BBcode

早过忘川 提交于 2020-01-06 21:15:28
问题 Say I have a document like: [b]blah[/b] [img]Thisismyimage.png[/img] How can I make it so that I completely remove all of the BBcode tags. And also remove all the text from between the [img] tags. If it helps at all I am using an IPB board. If any knows of a way to easily to parse the BBcode that would be great, however, I am perfectly happy with just removing it. 回答1: Parsing BBcode is pretty much a solved task: http://pear.php.net/package/HTML_BBCodeParser - And that would also be the more

Regular expressions: Finding BB code in a piece of text

霸气de小男生 提交于 2020-01-04 15:33:23
问题 I'm trying to match on "url" BB code tag in a random piece of text. Example text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. [url]http://www.google.com[/url] Donec purus nunc, rhoncus vitae tempus vitae, [url=www.facebook.com]facebook[/url] elementum sit amet justo. I want to find both "url" tags from this text: [url]http://www.google.com[/url] [url=www.facebook.com]facebook[/url] I am not that good with regular expressions so this is as far as I could get: \[url(=[a-z]*)?\][a-z

Regular expressions: Finding BB code in a piece of text

非 Y 不嫁゛ 提交于 2020-01-04 15:33:10
问题 I'm trying to match on "url" BB code tag in a random piece of text. Example text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. [url]http://www.google.com[/url] Donec purus nunc, rhoncus vitae tempus vitae, [url=www.facebook.com]facebook[/url] elementum sit amet justo. I want to find both "url" tags from this text: [url]http://www.google.com[/url] [url=www.facebook.com]facebook[/url] I am not that good with regular expressions so this is as far as I could get: \[url(=[a-z]*)?\][a-z

Javascript BBCode Parser recognizes only first list element

拥有回忆 提交于 2020-01-02 08:17:54
问题 I have a really simple Javascript BBCode Parser for client-side live preview (don't want to use Ajax for that). The problem ist, this parser only recognizes the first list element: function bbcode_parser(str) { search = new Array( /\[b\](.*?)\[\/b\]/, /\[i\](.*?)\[\/i\]/, /\[img\](.*?)\[\/img\]/, /\[url\="?(.*?)"?\](.*?)\[\/url\]/, /\[quote](.*?)\[\/quote\]/, /\[list\=(.*?)\](.*?)\[\/list\]/i, /\[list\]([\s\S]*?)\[\/list\]/i, /\[\*\]\s?(.*?)\n/); replace = new Array( "<strong>$1</strong>", "

PHP - BBCode parser - recursive [quote] with regex and preg_replace

微笑、不失礼 提交于 2019-12-31 05:31:08
问题 i'm making my own bbcode parser, and i've a problem when i try to do the recursive quote. this is my code : function forumBBCode($str){ $format_search=array( '#\[quote=(.*?)\](.*?)\[/quote\]#is' ); $format_replace=array( '<blockquote class="quotearea"><i><a class="lblackbu" href="./index.php?status=userview&userv=$1">$1</a> wrote :</i><br />$2</blockquote>' ); $str=preg_replace($format_search, $format_replace, $str); $str=nl2br($str); return $str; } what i must add/edit to do a recursive

Remove BBCode tags and their content in PHP [duplicate]

穿精又带淫゛_ 提交于 2019-12-31 01:25:20
问题 This question already has answers here : Closed 8 years ago . Possible Duplicates: Recursive BBCode Parsing Strip BBCode via RegEx What is the best way to remove all BBCode tags of a string and their content in PHP? 回答1: <?php function stripBBCode($text_to_search) { $pattern = '|[[\/\!]*?[^\[\]]*?]|si'; $replace = ''; return preg_replace($pattern, $replace, $text_to_search); } echo stripBBCode($text_to_search); ?> demo 来源: https://stackoverflow.com/questions/6777257/remove-bbcode-tags-and

Java BBCode library [closed]

有些话、适合烂在心里 提交于 2019-12-28 10:06:29
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Has anybody used a good Java implementation of BBCode? I am looking at javabbcode : nothing to see kefir-bb : Listed as alpha BBcode parser in JBoss source code. Are there any better options? 回答1: The current version of KefirBB 0.6 is not listed as beta anymore. I find the KefirBB parser very easy to configure

How to convert HTML to BBCode

倖福魔咒の 提交于 2019-12-28 02:11:08
问题 I maintain a bulletin board that saves rich text messages in HTML. Now I need to migrate all those messages into Joomla Kunena bulletin board that requires BBCode representation of HTML. Is there any library to convert HTML to BBCode cleanly. There are bunch of scripts out there for BBCode to HTML but not the other way around. Thanks... 回答1: It should be doable with XSLT in text output mode : <xsl:output method="text"> … <xsl:template match="b|strong">[b]<xsl:apply-templates/>[/b]</xsl

BBCODE, preg_replace and double quotes

杀马特。学长 韩版系。学妹 提交于 2019-12-25 06:44:20
问题 preg_replace('/\[quote\=(.*?);(.*?)\](.*?)\[\/quote\]/ms', '<blockquote>Posted by: \1 at \2.<br/>\3</blockquote>', $text); This is what I use to replace the [quote=user;id]content[/quote] bbcode. Anyway, it works fine only, if there is one quote in post. If I got: [quote=user1;1] [quote=user0;0]some content here[/quote] this is my reply to user0 post[/quote] It'll replace only first quote, other will be just not replaced by the <blockquote> . How can I fix that? 回答1: tested, repaired version