We can use split function to break the string using a delimiter.
For example -
Consider a string "pune*chennai*delhi*mumbai"
Now if you want to break the string you can do it using split function.
cities = "pune*chennai*delhi*mumbai"
arrayOfCities = split(cities,"*")
'Split function returns the sub strings in the form of array - (here arrayOfCities ).
For i=0 to ubound(arrayOfCities)
Print arrayOfCities(i)
next
The syntax of Split function is given below -
Split(Stringtosplit ,delimiter, occurence_Count, comparison_method)
In this function last 3 parameters are optional.
For example -
Consider a string "pune*chennai*delhi*mumbai"
Now if you want to break the string you can do it using split function.
cities = "pune*chennai*delhi*mumbai"
arrayOfCities = split(cities,"*")
'Split function returns the sub strings in the form of array - (here arrayOfCities ).
For i=0 to ubound(arrayOfCities)
Print arrayOfCities(i)
next
The syntax of Split function is given below -
Split(Stringtosplit ,delimiter, occurence_Count, comparison_method)
In this function last 3 parameters are optional.
Default delimiter is space.
occurence_Count ->how many substrings should be returned in the array.
comparison_method -> This parameter will tell what kind of comparison should be used. i.e binary(case-sensitive) or textual (case-insensitive).
Please give your inputs, suggestions, feedback to Us. We value your thoughts.
comparison_method -> This parameter will tell what kind of comparison should be used. i.e binary(case-sensitive) or textual (case-insensitive).
More interview questions and answers on strings in QTP
- What are the different string functions in QTP?
- How to extract the digits from given string in QTP?
- How to sort the array of strings in qtp
- How to get the first character in string in QTP?
- How to convert the string into upper case in QTP?
- How to get the last character from the string in QTP?
- How to replace the string in qtp?
- How to check if substring exists in QTP?
- Explain right, mid and left functions in qtp?
- How to remove the spaces from string in qtp?
- What are the trim functions in qtp?
- Explain replace function in qtp with example.
- Explain the split function in qtp with example.
- Explain lcase and ucase functions in qtp.
- What is the len function in qtp?
- Give the example of instr function in qtp
- What is the difference between dictionary and array in QTP?
- How to create dynamic 2 dimensional array in QTP?
- How to sort array of strings in qtp?
- How to create array of dictionary in qtp?
- How to define or declare array in qtp?
- How to return array from function in qtp?
- How to find the length of array in qtp?
- How to find the size of array in qtp?
- Explain the ubound function in qtp.
- Explain the split function in qtp with example.
- What is dotnetfactory object in qtp?
Please give your inputs, suggestions, feedback to Us. We value your thoughts.
No comments:
Post a Comment
Please Leave your reply. We value your feedback and inputs