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
Explain the difference between check point and output value?
How to start recording using quicktest professional (qtp)?
How to use conditional loops in qtp ?
Hi Friends this is kumar i would like to request to all of you ,please help me to explain real time project with using qtp scripts i know basics of qtp but it won't workout on interviews,pls help awating to reply.
How did you resolve conflicts present in Object Repository?
How to interact tool & application build in QTP?
How to check feasibility of the appliction?in automation testing?
Explain types of output values?
How many ways we can parameterize data in quicktest professional?
How to break the object spy ?
Do you know how to connect database? Can you tell me the procedures?
Get the count of files of similar types from a folder.
What is the framework your company is following. What is the reason. Explain why key word driven frame work is chosen.
What is TOM in QTP?
what is run-time data?