本文整理汇总了PHP中string::rereplace方法的典型用法代码示例。如果您正苦于以下问题:PHP string::rereplace方法的具体用法?PHP string::rereplace怎么用?PHP string::rereplace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string
的用法示例。
在下文中一共展示了string::rereplace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* @brief Parse the human data and return html
*
* @param string $data The data to parse
* @return string The parsed data
*/
public function parse($content)
{
$str = $content;
$str = string::rereplace($str, '/</', '<');
$str = string::rereplace($str, '/>/', '>');
$str = string::rereplace($str, '/\\\\"/', '"');
// First chunk everything into paragraphs...
$str = string::rereplace($str, '/(.+)/', '<p>\\1</p>');
// Then take care of multiple newlines
$str = string::rereplace($str, '/(\\r|\\n){2}/', '<br>');
// The usual, bold, italics, etc...
$str = string::rereplace($str, '/\\/(.*?)\\//', '<em>\\1</em>');
$str = string::rereplace($str, '/\\*(.*?)\\*/', '<strong>\\1</strong>');
$str = string::rereplace($str, '/_(.*?)_/', '<u>\\1</u>');
$tag_re = '/\\#([a-zA-Z0-9]+)/s';
$group_re = '/\\!([a-zA-Z0-9]+)/s';
/*
preg_match_all($tag_re, $content, $tags);
preg_match_all($group_re, $content, $groups);
$this->setMeta(MarkupParser::META_TAGS, $tags[1]);
$this->setMeta(MarkupParser::META_GROUPS, $groups[1]);
*/
$str = string::rereplace($str, $tag_re, '<a href="/tags/\\1">#\\1</a>');
$str = string::rereplace($str, $group_re, '<a href="/groups/\\1">!\\1</a>');
$str = string::rereplace($str, '/\\@([a-zA-Z0-9]+)/s', '<a href="/user/\\1">@\\1</a>');
// A bit of a hack...but it works... let me know if you have a regex that fixes this :p
$str = string::rereplace($str, '/<strong><\\/strong>/', '**');
$str = string::rereplace($str, '/<em><\\/em>/', '//');
$str = string::rereplace($str, '/<u><\\/u>/', '__');
$str = string::rereplace($str, '/(https?:\\/\\/\\S+)/', '<a href="\\1" rel="nofollow">\\1</a>');
return $str;
}