ActionScript find LineBreak in XML and count them
        Posted  
        
            by Pepe Sanchez
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Pepe Sanchez
        
        
        
        Published on 2010-04-07T19:40:52Z
        Indexed on 
            2010/04/07
            19:43 UTC
        
        
        Read the original article
        Hit count: 390
        
Hi, i have an XML that has line breaks like this:
This is a text that has
line
breaks
im reading that xml in action script.. and trying to count how many linebreaks are in the text.
Here is my code.. it returns 0 , it should return 5 for the example.
function countBreaks(str:String) : Number
{
 var count:Number = 0;
 for (var i:Number = 0; i < str.length-1; i++)
 {
  if(str.charAt(i)+str.charAt(i+1) eq "\n")
             count++;
 }
 return count;
}
I appreciate any help :)
© Stack Overflow or respective owner