How to count word instances in a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darko
    New Member
    • Sep 2006
    • 10

    #1

    How to count word instances in a string

    hello im doing a small rss project and i'm stuck at trying to count how many items are in the feed, my question is: how can i count the instances of a word, in this case <item> in a string(source), thanks
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    You could do a string.split which will produce an array, then count the number of elements.

    Comment

    • darko
      New Member
      • Sep 2006
      • 10

      #3
      yeah, thought of that, but string.split will only split at the first occurrence so i'll end up with an array of 2 elements

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        Who told you that hogwash?
        You should actually look things up rather than trusting locker room gossip.

        [imgnothumb]http://files.me.com/tlhintoq/ggkfk3[/imgnothumb]

        Comment

        • darko
          New Member
          • Sep 2006
          • 10

          #5
          thanks alot dude, that did the trick!!

          Comment

          Working...