Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Is there a function to find the number of occurrences of sub
strings within a string?

Answer Posted / nath t

The below function returns number of occurrences of sub
string within a string

Function SubStrOccur(Str, SubStr)
Occr = split(Str, SubStr)
SubStrOccur = ubound(Occr)
End Function

Scenario 1:

Str = "SairamSairam Sairam"
SubStr = "Sai"
msgbox "Given SubString("&SubStr&") appeared "&SubStrOccur
(Str, SubStr)&" time(s) in given String("&Str&")"

Function return 3 (bcz "Sai" appears 3 times in the given
string.)



Scenario 2:

Str = "SairamSairam Sairam"
SubStr = "sai"
msgbox "Given SubString("&SubStr&") appeared "&SubStrOccur
(Str, SubStr)&" time(s) in given String("&Str&")"

Function return 0 (bcz here "sai" is in small letters
doesn't appear in the given string.)

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Did QTP prove efficient for your project? Yes or No, explain?

6595


Excel sheet having some datas and some datas present in the application (in table). How will you compare these two datas? Write code to fetch datas from Excel sheet.

1973


When using descriptive programming?

1077


How do you configure QTP AND Test director?

1932


What is quicktest professional (qtp)?

1031


What is the use of text output value in quicktest professional?

968


I want to open a Notepad window without recording a test and I do not want to use System utility Run command as well. How do I do this?

1187


"What are the common constrains that we need to consider when we prepare testcases for ASP application". Thanks in Advance...

1989


www.icici.com after this home page wll came, in this page what r the items we r going to test for manual and what the element we r test for QTP... explian clearly with example

2030


What are the major/ important methods, functions in QTP we use realtime testing

2785


what is description object?

2040


How you can delete excel file in qtp?

1062


Differences between text and test area checkpoints?

1099


What contains Data Driven Framework document in qtp?

1970


what type of values given to objects. EX::Set oBrowser=Description.Create oBrowser(“micclass”).Value=”Browser”

1948