12 Replies Latest reply on Feb 26, 2007 2:05 PM by kglad

    Word count function

    golem2
      Hi ,
      Anyone has a good word count function? One that will ignore long white spaces and newlines?

      Many thanks

      Golem
        • 1. Re: Word count function
          kglad Adobe Community Professional & MVP
          add numbers to s if you want to count numbers as words and adjust for hyphenated words if you want to count them as two words:

          • 2. Re: Word count function
            golem2 Level 1
            cheers kglad!
            • 3. Re: Word count function
              kglad Adobe Community Professional & MVP
              you're welcome.
              • 4. Re: Word count function
                golem2 Level 1
                Hi kglad

                The function work good, but it seems to count words like : "You’ll" "that’s" "He’s"
                as two words....

                thanks
                • 5. Re: Word count function
                  kglad Adobe Community Professional & MVP
                  i don't see that.
                  • 6. Re: Word count function
                    golem2 Level 1
                    ....mm
                    you are right it is some other charachter that sneeks in when copy and paste from word to flash.
                    the way I use the function is I read a string from a textfield adn count it.
                    works of for input text. but when I paste some text from word to dynamic textfield
                    It looks ok but add some extras to the counting. I do the folowing to see these extra bits:
                    copy from word to flash, then copy from flash back to word... and I get some extra chars looks like that:


                    from word:

                    We just moved here over the summer,” said Hoppy.
                    “What’s your dad like?” Gerald asked.
                    “He’s great. We go surfing together when he gets home from work.”


                    then paste in flash.
                    copy and paste back in word, I get:


                    We just moved here over the summer,î said Hoppy.
                    ìWhatís your dad like?î Gerald asked.
                    ìHeís great. We go surfing together when he gets home from work.î

                    any idea, why?
                    • 7. Re: Word count function
                      golem2 Level 1
                      well, chackei it again and it is the function,I think it counts wrong some quatation marks.

                      the folloing text in word counts 152, the function counts 159.

                      I don't fully understand the function to try to debug it.

                      -----------------
                      Hoppy and Gerald went back to the garage to get their bikes. Hoppy’s mom was in the garden again.
                      “I’ll ride back to Gerald’s house with him,” Hoppy said.
                      “You’ll need to get those glasses fixed better, Gerald,” said Mom. She wrapped a blue bandage around them, too.
                      “I will. Bye and thanks again,” Gerald said, as the boys got on their bikes.
                      “Where to?” asked Hoppy.
                      “Up by the park,” replied Gerald.
                      As they rode along, Gerald asked, “Why do you hang around with those kids?”
                      “I only met them today,” said Hoppy. “I thought they were cool. But I was wrong.”
                      “Wow, that’s a relief. I really thought they were your friends,” said Gerald.
                      “I don’t know anyone yet, except Mom and Dad. We just moved here over the summer,” said Hoppy.
                      “What’s your dad like?” Gerald asked.
                      “He’s great. We go surfing together when he gets home from work.”
                      • 8. Re: Word count function
                        kglad Adobe Community Professional & MVP
                        i don't see a problem. and my function counts 145 words in your last post below the dotted line.
                        • 9. Re: Word count function
                          golem2 Level 1
                          well, that is strange. The text have 152 words. you count 145 I get 159 .....
                          anyhow, here is the solution that produces the correct counting:

                          - add all caps to s on first line...

                          cheers,
                          Golem2
                          • 10. Re: Word count function
                            kglad Adobe Community Professional & MVP
                            the correction should be:

                            • 11. Re: Word count function
                              golem2 Level 1
                              cheers kglad
                              • 12. Re: Word count function
                                kglad Adobe Community Professional & MVP
                                yes, tempS.toLowerCase() doesn't change tempS. it returns a lower case string but doens't modify the original and i failed to account for that in the first code i suggested.