find in string

Discussion in 'ASP General' started by Bite My Bubbles, Aug 9, 2003.

  1. How can i count the number of times a string appears within another string.
    Thanks a
    lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    !!
     
    Bite My Bubbles, Aug 9, 2003
    #1
    1. Advertising

  2. Bite My Bubbles

    dlbjr Guest

    Check out Regular Expressions.


    -dlbjr

    invariable unerring alien
     
    dlbjr, Aug 9, 2003
    #2
    1. Advertising

  3. Bite My Bubbles

    Evertjan. Guest

    Manohar Kamath [MVP] wrote on 09 aug 2003 in
    microsoft.public.inetserver.asp.general:
    > Dim arElem
    > Dim myString
    > Dim mySubString
    >
    > myString = "this contains the word how many times just one time"
    > mySubString = "how many times"
    > arElem = Split(myString, mySubString)
    >
    > Response.Write("Number of times: " & UBound(arElem))


    The case insensitive way, often used by me:

    MyNum = UBound(Split(ucase(myString), ucase(mySubString)))
    Response.Write "Number of times: " & myNum

    This also does not keep a large array in memory, (I hope).

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Aug 9, 2003
    #3
  4. that;s a good one thanks
    "Manohar Kamath [MVP]" <> wrote in message
    news:...
    > One way to do this is kinda a round about way. Use the Split function to
    > split the string into an array, and count the number of array elements,
    > minus one.
    >
    > Dim arElem
    > Dim myString
    > Dim mySubString
    >
    > myString = "this contains the word how many times just one time"
    > mySubString = "how many times"
    > arElem = Split(myString, mySubString)
    >
    > Response.Write("Number of times: " & UBound(arElem))
    >
    > You could also use the InStr function, and loop through the first ring to
    > count number of times the string appears.
    >
    > --
    > Manohar Kamath
    > Editor, .netBooks
    > www.dotnetbooks.com
    >
    >
    > "Bite My Bubbles" <> wrote in message
    > news:...
    > > How can i count the number of times a string appears within another

    > string.
    > > Thanks a
    > >

    >

    lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    > > !!
    > >
    > >

    >
    >
     
    Bite My Bubbles, Aug 9, 2003
    #4
  5. that's a good one too!

    "Evertjan." <> wrote in message
    news:Xns93D264429E3CFeejj99@194.109.133.29...
    > Manohar Kamath [MVP] wrote on 09 aug 2003 in
    > microsoft.public.inetserver.asp.general:
    > > Dim arElem
    > > Dim myString
    > > Dim mySubString
    > >
    > > myString = "this contains the word how many times just one time"
    > > mySubString = "how many times"
    > > arElem = Split(myString, mySubString)
    > >
    > > Response.Write("Number of times: " & UBound(arElem))

    >
    > The case insensitive way, often used by me:
    >
    > MyNum = UBound(Split(ucase(myString), ucase(mySubString)))
    > Response.Write "Number of times: " & myNum
    >
    > This also does not keep a large array in memory, (I hope).
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
     
    Bite My Bubbles, Aug 9, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    17
    Views:
    831
    Hiran Chaudhuri
    Dec 6, 2005
  2. petry

    std::string::find vs std::find

    petry, Jul 5, 2009, in forum: C Programming
    Replies:
    1
    Views:
    350
    petry
    Jul 5, 2009
  3. Wybo Dekker
    Replies:
    1
    Views:
    366
    Yukihiro Matsumoto
    Nov 15, 2005
  4. vdvorkin
    Replies:
    0
    Views:
    414
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    817
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page