QTP supports lot of string functions.
Some of the commonly used string manipulation functions are given below.
Examples -
myString = "Sachin Plays Cricket"
print right(myString,7)
'will return the 7 characters from the right side of myString
'Cricket
print left(myString,6)
'will return the 6 characters from the left side of myString
'Sachin
print mid(myString,8,5)
'will return the 5 characters from the 8th position of myString
'Plays
Syntax -
Second parameter in left and right function tells how many characters to return from the string.
In mid functions there are 2 parameters. First parameter tells from which position of the string we have to get the characters and second parameter tells how many characters to return.
Please give your inputs, suggestions, feedback to Us. We value your thoughts.
Some of the commonly used string manipulation functions are given below.
- right
- mid
- left
All of the above functions are frequently used when performing any string operations in QTP.
All of the above functions extract the part of the string / Sub string.
Right function returns the fixed number of characters from right side of the string.
Left function returns the fixed number of characters from left side of the string.
Mid function can be used to get the characters/ sub string from the left, right or middle part of the string.
Examples -
myString = "Sachin Plays Cricket"
print right(myString,7)
'will return the 7 characters from the right side of myString
'Cricket
print left(myString,6)
'will return the 6 characters from the left side of myString
'Sachin
print mid(myString,8,5)
'will return the 5 characters from the 8th position of myString
'Plays
Syntax -
Second parameter in left and right function tells how many characters to return from the string.
In mid functions there are 2 parameters. First parameter tells from which position of the string we have to get the characters and second parameter tells how many characters to return.
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
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