06-07-2010, 10:54 PM
Thanks basanth27 and I agree. Using loops does slow down the scripting language, so you need to be wary.
At the same point to test every character in a string to find numbers is a loop (for next). I found that using RE is most beneficial in a function that you can then reuse whenever necessary by just changing the expression. You only need the loop if you want to return the underlying matching string, which in this example is wanted. Just returning a boolean doesn't need the loop at all and performs extremely quick in QTP.
I am not aware of any specific HP string testing. Looks like all VBScript string functions to me of which Regular Expression is built in too. Do you have an example of HP functions?
As with all things in development coding, there are many ways to accomplish the tasks at hand. I have used both methods in the past and have only recently become a RE convert. This is just my way to do the requested job and provide a reusable function because I hate rewriting code over and over.
At the same point to test every character in a string to find numbers is a loop (for next). I found that using RE is most beneficial in a function that you can then reuse whenever necessary by just changing the expression. You only need the loop if you want to return the underlying matching string, which in this example is wanted. Just returning a boolean doesn't need the loop at all and performs extremely quick in QTP.
Quote:available string functions supplied by HP dev
I am not aware of any specific HP string testing. Looks like all VBScript string functions to me of which Regular Expression is built in too. Do you have an example of HP functions?
As with all things in development coding, there are many ways to accomplish the tasks at hand. I have used both methods in the past and have only recently become a RE convert. This is just my way to do the requested job and provide a reusable function because I hate rewriting code over and over.