Thursday, 1 August 2013

Explain right, mid, left functions in QTP with Examples.

QTP supports lot of string functions.
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

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

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.