[img]src[/img]
을 <img src="src" alt="src" >
으로 정규 표현식으로 변경하고 싶습니다.PHP : 정규 표현식으로 [img] src [/ img]를 <img src="src" alt="src" > (으)로 변경하십시오.
<img src="">
을 [img][/img]
으로 변환하는 일부 사례를 발견했지만 내 사례는 발견하지 못했습니다.
감사합니다.
[img]src[/img]
을 <img src="src" alt="src" >
으로 정규 표현식으로 변경하고 싶습니다.PHP : 정규 표현식으로 [img] src [/ img]를 <img src="src" alt="src" > (으)로 변경하십시오.
<img src="">
을 [img][/img]
으로 변환하는 일부 사례를 발견했지만 내 사례는 발견하지 못했습니다.
감사합니다.
을 테스트 할 수 있습니다를 ...
http://thesinkfiles.hubpages.com/hub/Regex-for-BBCode-in-PHP
function parseCode($txt)
{
// these functions will clean the code first
$ret = strip_tags($txt);
// code replacements
$ret = preg_replace('#\[b\](.+)\[\/b\]#iUs', '<b>$1</b>', $ret);
$ret = preg_replace('#\[link\=(.+)\](.+)\[\/link\]#iUs', '<a href="$1">$2</a>', $ret);
$ret = preg_replace('#\[img\](.+)\[\/img\]#iUs', '<img src="$1" alt="Image" />', $ret);
$ret = preg_replace('#\[quote\=(.+)\](.+)\[\/quote]#iUs', '<div class="quote">$2</div><div class="quote-by">By: $1</div>', $ret);
// return parsed string
return $ret;
}
$ret = preg_replace('#\[img\](.+)\[\/img\]#iUs', '<img src="$1" alt="img">', $ret);
일반적으로 전용 phpBB 스크립트 또는 phpBB 클래스와 같은 것을 원합니다. 심지어 PHP 자체가 BBCode는 텍스트 프로세서를 가지고 : http://www.php.net/manual/en/book.bbcode.php이
당신은 그것을 나는이 문서가 문제에 당신을 도울 것입니다 믿습니다
$str= preg_replace('~\[img\](.*)\[\/img\]~si', '<img src="$1" alt="$1">', $str);
보관하십시오. n이 명령 앞에 심각한 보안 결함을 피하기 위해'$ str'을 위생 처리해야한다는 것을 기억하십시오. (['htmlentities ($ str)'] (http://php.net/manual/en/function.htmlentities.php) – Yogu
@ Yogu ok. 하지만 나는 단지 더 이상 질문에 답하고 싶다. –
HTTP : //stackoverflow.com/questions/1799454/is-there-a-solid-bb-code-parser-for-php-that-doesnt-have-any-dependancies – Mez