Tuesday, 30 July 2013

How to extract digits from a given string in QTP?


Below example will show how to extract digits from a given string in QTP.


Mystr = "Order number is 3445456"
Set myRegExp = New RegExp
'Create a regular expression object

myRegExp.Global = True
myRegExp.Pattern = "[^\d]"

'set the pattern to non-digital characters

strDigits = myRegExp.Replace(Mystr, "")

'replace all non - digit characters by empty string.

Print strDigits

'Prints 3445456

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.