$pattern = '/(?:src=")(:?.*)(kcfinder(.*)\" (?:s))/';
$string = preg_replace($pattern, 'src=$2', $string);
$pattern = '/(?:src=")(:?.*)(kcfinder(.*)\" (?:s))/';
$string = preg_replace($pattern, 'src=$2', $string);
$pattern = '/(?:src=")(:?.*)(kcfinder(.*)\" (?:s))/';
$string = preg_replace($pattern, 'src="$2', $string);
$pattern = '/(src=")(.*)(kcfinder(.*)\" (?:s))/';
$string = preg_replace($pattern, '$1$3', $string);
Цитата (OleKh @ 16.01.2013 - 00:02) |
а так$pattern = '/(?:src=")(:?.*)(kcfinder(.*)\" (?:s))/'; |
Цитата (OleKh @ 16.01.2013 - 00:14) |
или даже так должно быть лучше$pattern = '/(src=")(.*)(kcfinder(.*)\" (?:s))/'; |
$string = preg_replace($pattern, '', $string);
Цитата (OleKh @ 16.01.2013 - 00:18) |
$string = preg_replace($pattern, '', $string); а почему пустые замены? |
$string ='<p>
<img alt="" src="/mmm/kcfinder/upload/images/1.34.jpg" style="width: 239px; height: 115px;" /></p>
<p>
текст текст </p>
<div>
<img alt="" src="/mmm/kcfinder/upload/images/1.11 1.12 1.13.jpg" style="width: 555px; height: 148px;" /></div>
<div>
<p>
текст текст</p>
<div>
<p>
</p>
</div>
$pattern = '/(src=")(.*)(kcfinder(.*)\" (?:s))/';
$string = preg_replace($pattern, '$1$3', $string);
var_dump ($string );
$str = preg_replace('#(<img[^>]+src=")[^">]+(/kcfinder/)#i', '$1$2', $str);
var_dump ($Text_str );
$pattern = '/(src=")(.*)(kcfinder(.*)\" (?:s))/';
$Text = preg_replace($pattern, '$1$3', $Text_str);
var_dump ($Text );
string(263) "<p>
<span data-scayt_word=\"текст\" data-scaytid=\"1\">текст</span></p>
<p>
<img alt=\"\" src=\"/mmm/kcfinder/upload/images/1.34P.jpg\" style=\"width: 251px; height: 111px;\" /></p>
<p>
<span data-scayt_word=\"текст\" data-scaytid=\"2\">текст</span></p>
"
string(263) "<p>
<span data-scayt_word=\"текст\" data-scaytid=\"1\">текст</span></p>
<p>
<img alt=\"\" src=\"/mmm/kcfinder/upload/images/1.34P.jpg\" style=\"width: 251px; height: 111px;\" /></p>
<p>
<span data-scayt_word=\"текст\" data-scaytid=\"2\">текст</span></p>
"
Цитата (killer8080 @ 16.01.2013 - 00:28) |
$str = preg_replace('#(<img[^>]+src=")[^">]+(/kcfinder/)#i', '', $str); |
var_dump ($Text_str );
$pattern = '#(<img[^>]+src=")[^">]+(/kcfinder/)#i';
$Text = preg_replace($pattern, '$1$2', $Text_str);
var_dump ($Text );
<p>
<span data-scayt_word=\"текст\" data-scaytid=\"3\">текст</span></p>
<p>
<img alt=\"\" src=\"/mmm/kcfinder/upload/images/1.34P.jpg\" style=\"width: 251px; height: 111px;\" /></p>
<p>
<span data-scayt_word=\"текст\" data-scaytid=\"4\">текст</span></p>
<p>
<span data-scayt_word=\"текст\" data-scaytid=\"3\">текст</span></p>
<p>
<img alt=\"\" src=\"/mmm/kcfinder/upload/images/1.34P.jpg\" style=\"width: 251px; height: 111px;\" /></p>
<p>
<span data-scayt_word=\"текст\" data-scaytid=\"4\">текст</span></p>