Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Counting Strings Found

    Hi, i'm wondering if anyone knows of a way to count how many times a certain string is found within a variable.

    Say i had:

    var blah="Here is a string";

    And i wanted to count how many times it found an 'i' in that, how might i go about doing that?

    Thanks.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    var nri=blah.split('i').length-1;
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    May 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot That works great


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •