Encerrado

Simple PHP regex/preg_replace bug

Hi,

I am using preg_replace to replace two line breaks with p tag. See code below. The problem I am getting is that for some of the text it put empty p tags and I can't figure out whats wrong with my code.

Can you please have a look and let me know if you can fix it.

<p><![CDATA['.contentXMLParse('content goes here').']]></p>

function contentXMLParse($content){

$content = trim($content);

$output = preg_replace('/\n\r|\r\n|\n\n|\r\r/', "]]></p><p><![CDATA[", $content);

return $output;

}

Many Thanks

Habilidades: Amazon Web Services, Engenharia, Perl, PHP, Arquitetura de software, Teste de Software, Hospedagem Web, Gestão de Site , Teste de Website

Ver mais: regex is, regex c, regex &, Regex, php regex, c++ regex, c regex, problem regex php, regex tag, regex php, text line breaks, simple figure, cdata, simple regex, simple text replace, simple php function, text replace perl, replace text text php, replace perl, preg php, perl getting line text, using regex, perl line text, line text perl, perl replace tags

Acerca do Empregador:
( 210 comentários ) Leeds, United Kingdom

ID do Projeto: #3034061

15 freelancers estão ofertando em média $19 para este trabalho

s17

See private message.

$8.5 USD in 14 dias
(369 Comentários)
6.5
matfizvw

See private message.

$59.5 USD in 14 dias
(55 Comentários)
6.1
rexhauser

See private message.

$7.65 USD in 14 dias
(90 Comentários)
5.2
hrvoje89ri

See private message.

$42.5 USD in 14 dias
(14 Comentários)
4.7
pateman

See private message.

$8.5 USD in 14 dias
(52 Comentários)
4.7
alexanderlim

See private message.

$11.05 USD in 14 dias
(43 Comentários)
4.6
rickeisermannvw

See private message.

$12.75 USD in 14 dias
(30 Comentários)
4.5
sukarelawatilx

See private message.

$6.8 USD in 14 dias
(82 Comentários)
4.4
ezgontechno

See private message.

$63.75 USD in 14 dias
(4 Comentários)
4.2
stianlik

See private message.

$17 USD in 14 dias
(11 Comentários)
3.7
LChristian

See private message.

$17 USD in 14 dias
(8 Comentários)
3.6
sunny05tt

See private message.

$6.8 USD in 14 dias
(22 Comentários)
3.6
gsmsl

See private message.

$8.5 USD in 14 dias
(17 Comentários)
2.8
hani01

See private message.

$8.5 USD in 14 dias
(5 Comentários)
1.1
cfsalguero

See private message.

$12.75 USD in 14 dias
(0 Comentários)
0.0
fblaser

See private message.

$5.1 USD in 14 dias
(0 Comentários)
0.0