Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > find in string

Reply
Thread Tools

find in string

 
 
Bite My Bubbles
Guest
Posts: n/a
 
      08-08-2003
How can i count the number of times a string appears within another string.
Thanks a
lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!
!!


 
Reply With Quote
 
 
 
 
dlbjr
Guest
Posts: n/a
 
      08-09-2003
Check out Regular Expressions.


-dlbjr

invariable unerring alien


 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      08-09-2003
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)
 
Reply With Quote
 
Bite My Bubbles
Guest
Posts: n/a
 
      08-09-2003
that;s a good one thanks
"Manohar Kamath [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > How can i count the number of times a string appears within another

> string.
> > Thanks a
> >

>

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

>
>



 
Reply With Quote
 
Bite My Bubbles
Guest
Posts: n/a
 
      08-09-2003
that's a good one too!

"Evertjan." <(E-Mail Removed)> 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)



 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to exclude action of Find::Find::find in subdirectories withknown names? vdvorkin Perl Misc 3 02-14-2011 05:28 AM
How to exclude action of Find::Find::find in subdirectories withknown names? vdvorkin Perl Misc 0 02-10-2011 05:18 PM
std::string::find vs std::find petry C++ 1 07-05-2009 01:49 PM
Help: what is the quickest way to find out whether a string contains another string? tuweiwen@gmail.com Java 17 12-06-2005 01:04 PM
Find.find does not find orphaned links? Wybo Dekker Ruby 1 11-15-2005 02:50 PM



Advertisments