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 differences between table and db checkpoints?
Pls can anybody send me the Recent Technical and Interview Questions Which were asked in IBM(QTP)Automation PLZZZZZZZZZ
How reliable are the site's Internet connections required to be? And how does that affect backup system or redundant connection requirements and testing?
Please guide me release notes of Automation once scripts are completed
What are private functions in QTP? How they can be called from the function library?
How qtp recognizes the object?
What are the differences between quicktest professional and winrunner?
Explain how qtp identifies object?
Can any one tell me how to write a script for selecting open option in File menu of A word document.here you have to add objects to OR.try like that and give me the ans.i asked this question to so many but no one knows.if any one know the answer plz let me know
How you can make an action as re-usable action?
What is test object?
How to give a call to another action from one action?
How to test fly out menu in qtp?
wht type of User defined functions or Java Releated functions do we write in VB scripting
What are the benefits of quick test pro(qtp)?