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
Did QTP prove efficient for your project? Yes or No, explain?
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.
When using descriptive programming?
How do you configure QTP AND Test director?
What is quicktest professional (qtp)?
What is the use of text output value in quicktest professional?
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?
"What are the common constrains that we need to consider when we prepare testcases for ASP application". Thanks in Advance...
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
What are the major/ important methods, functions in QTP we use realtime testing
what is description object?
How you can delete excel file in qtp?
Differences between text and test area checkpoints?
What contains Data Driven Framework document in qtp?
what type of values given to objects. EX::Set oBrowser=Description.Create oBrowser(“micclass”).Value=”Browser”