Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 07:30 AM
Bite My Bubbles
Guest
 
Posts: n/a
Default find in string

How can i count the number of times a string appears within another string.
Thanks a
lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!
!!


  #2  
Old July 19th, 2005, 07:30 AM
dlbjr
Guest
 
Posts: n/a
Default Re: find in string

Check out Regular Expressions.


-dlbjr

invariable unerring alien


  #3  
Old July 19th, 2005, 07:30 AM
Evertjan.
Guest
 
Posts: n/a
Default Re: find in string

Manohar Kamath [MVP] wrote on 09 aug 2003 in
microsoft.public.inetserver.asp.general:[color=blue]
> 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))[/color]

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)
  #4  
Old July 19th, 2005, 07:30 AM
Bite My Bubbles
Guest
 
Posts: n/a
Default Re: find in string

that;s a good one thanks
"Manohar Kamath [MVP]" <mkamath@TAKETHISOUTkamath.com> wrote in message
news:uCnZc0gXDHA.1280@tk2msftngp13.phx.gbl...[color=blue]
> 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" <bmb@mybubbles.com> wrote in message
> news:eT6gNQgXDHA.1620@TK2MSFTNGP12.phx.gbl...[color=green]
> > How can i count the number of times a string appears within another[/color]
> string.[color=green]
> > Thanks a
> >[/color]
>[/color]
lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!![color=blue][color=green]
> > !!
> >
> >[/color]
>
>[/color]


  #5  
Old July 19th, 2005, 07:30 AM
Bite My Bubbles
Guest
 
Posts: n/a
Default Re: find in string

that's a good one too!

"Evertjan." <exjxw.hannivoort@interxnl.net> wrote in message
news:Xns93D264429E3CFeejj99@194.109.133.29...[color=blue]
> Manohar Kamath [MVP] wrote on 09 aug 2003 in
> microsoft.public.inetserver.asp.general:[color=green]
> > 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))[/color]
>
> 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)[/color]


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles