Here I will take you through different string functions which are used on daily basis in scripting. I can also say this as an step up for the interview.
> Len(string) - This function is used to find the length of any given string.
With this function, you can directly pass a string as an argument and we can get the length of it.
>LCase(string) - This function is used to convert the upper case of characters in lower case. If the string is already in lower case then it will remain as it is.
>UCase(string) - This function is used to convert the lower case of characters into upper case. If the string is already in upper case then it will remain as it is.
>LTrim(String) - LTrim is used to remove a leading space from any string.
>RTrim(String) - RTrim is used to remove a trailing space from any string.
>Trim(String) - Trim is used to remove the leading and trailing space from any string.
>InStr([start,]string1,string2[,compare])
This function searches for a string within another another string and returns the location of occurrence of one string within another string.It actually returns the position of first occurrence of the second string within first
>InstrReverse(String1, string2, start position, compare)
it returns the occurence of second string from the first but this starts the comparison from last.
>Left(String,no of characters) - Left function returns the specified number of characters from left side of the string
>Right(String , No of characters) - Right function returns specified number of characters from right side of the string.
>Mid(String, Start position, no of characters) - Mid function returns specified number of characters from the given start position.
>StrReverse(String) - This function reverses the given string.
>StrComp(String1,string2,binary(0)/textual(1)) - Strcomp is used to compare two strings. We can decide the binary and textual comparison by giving the 3rd parameter as 0 or 1. Binary comparison also checks for the case of the characters and textual comparison only checks for the test of the strings.
>Replace(expression, expression to be replaced, Start position, no of replacements ,binary(0)/textual(1) comparison)
Replace function is used to replace the given character from the given expression. The last 3 parameters are optional. We can give the start position if we want any particular position to be checked. We can also give the number of replacements and at last we can do replacement by binary or textual comparison.
>Space(no of spaces)
This is a simple function which is used to give space in a particular string or at any place. We can give the count of no of spaces we want.
>Split(expression, delimiter, count ,compare)
Split is used to split or seperate the given expression with the given delimiter(eg-space,comma,etc). The last 2 parameters are optional, the count is used to give the no till where we want to split the expression and -1 is the default value of it.
So this was most of the string functions used in QTP, a quick revision of it favours a lot in the interviews!!
> Len(string) - This function is used to find the length of any given string.
With this function, you can directly pass a string as an argument and we can get the length of it.
>LCase(string) - This function is used to convert the upper case of characters in lower case. If the string is already in lower case then it will remain as it is.
>LTrim(String) - LTrim is used to remove a leading space from any string.
>RTrim(String) - RTrim is used to remove a trailing space from any string.
>Trim(String) - Trim is used to remove the leading and trailing space from any string.
>InStr([start,]string1,string2[,compare])
This function searches for a string within another another string and returns the location of occurrence of one string within another string.It actually returns the position of first occurrence of the second string within first
>InstrReverse(String1, string2, start position, compare)
it returns the occurence of second string from the first but this starts the comparison from last.
>Left(String,no of characters) - Left function returns the specified number of characters from left side of the string
>Right(String , No of characters) - Right function returns specified number of characters from right side of the string.
>Mid(String, Start position, no of characters) - Mid function returns specified number of characters from the given start position.
>StrReverse(String) - This function reverses the given string.
>StrComp(String1,string2,binary(0)/textual(1)) - Strcomp is used to compare two strings. We can decide the binary and textual comparison by giving the 3rd parameter as 0 or 1. Binary comparison also checks for the case of the characters and textual comparison only checks for the test of the strings.
>Replace(expression, expression to be replaced, Start position, no of replacements ,binary(0)/textual(1) comparison)
Replace function is used to replace the given character from the given expression. The last 3 parameters are optional. We can give the start position if we want any particular position to be checked. We can also give the number of replacements and at last we can do replacement by binary or textual comparison.
>Space(no of spaces)
This is a simple function which is used to give space in a particular string or at any place. We can give the count of no of spaces we want.
>Split(expression, delimiter, count ,compare)
Split is used to split or seperate the given expression with the given delimiter(eg-space,comma,etc). The last 2 parameters are optional, the count is used to give the no till where we want to split the expression and -1 is the default value of it.
So this was most of the string functions used in QTP, a quick revision of it favours a lot in the interviews!!
No comments:
Post a Comment