php regex [b]到< b> [英] php regex [b] to <b>

查看:85
本文介绍了php regex [b]到< b>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  "'\[b\](.*?)\[/b\]'is",

我当前的RegEx是否正常工作.但是我想将[]改为<>.但这是行不通的……我还需要更改[].

Is my current RegEx working. But I want to change the [] to be <> instead. But it doesn't work... What more then just the [] do I need to change.

推荐答案

  • http://www.php.net/manual/zh/book .bbcode.php
  • 这使您可以轻松地手动定义替换规则:

    which allows you to simply define your replacement rules by hand:

    echo bbcode_parse(
        bbcode_create(
            array(
                'b' => array(
                    'type'      => BBCODE_TYPE_NOARG,
                    'open_tag'  => '<b>',
                    'close_tag' => '</b>'
                )
            )
        ),
        '[b]Bold Text[/b]'
    );
    // prints <b>Bold Text</b>
    

    还要检查有关BBCode解析器的各种类似问题:

    Also check the various similar questions about BBCode Parsers:

    这篇关于php regex [b]到&lt; b&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆