Count("<p>") in a string

i want to count the number of paragraphs in my message of an article ,
but it gives the wrong number

example of paragraph :

Dick Advocaat verdient veel geld bij Zuid-Korea

De Zuid-Koreaanse voetbalbond legt de Nederlandse bondscoach Dick Avocaat rijkelijk in de watten. De lokale media melden dat Advocaat per jaar 605.000 euro opstrijkt. Zijn loon zou een half miljoen euro bedragen. De verblijfskosten bedragen 75.000 euro en het tekengeld 25.000. Advocaat krijgt ook een kleine onkostenvergoeding om de hongerige maag te stillen.

number = self.message.count("

")

it gives 27 as result but is has to 2 , what’s my problem?

greetz

Klaas

Hi –

On Sat, 4 Mar 2006, klaas wrote:

onkostenvergoeding om de hongerige maag te stillen.

number = self.message.count(“

”)

it gives 27 as result but is has to 2 , what’s my problem?

It’s counting the total number of ‘>’, ‘p’, and ‘<’ characters. Try
this:

number = message.scan(“

”).size

David


David A. Black ([email protected])
Ruby Power and Light (http://www.rubypowerandlight.com)

“Ruby for Rails” chapters now available
from Manning Early Access Program! Ruby for Rails

thank you for your solution

klaas