Micro Focus QTP (UFT) Forums
"Regular Expression for my output" - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Regular Expressions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Regular-Expressions)
+--- Thread: "Regular Expression for my output" (/Thread-Regular-Expression-for-my-output)



"Regular Expression for my output" - suresz449 - 12-08-2011

Hi Folks,

while I run my script I am getting output like as Test_9UP_ab_UNIT.
In my output the value 9 and ab are changing dynamically so, please can any one give me the regular expression for the above string.




Thanks and Regards,
Suresh D


RE: "Regular Expression for my output" - ravi.gajul - 12-08-2011

Assuming UP is always preceeded by a anumber between 0-9 and _Unit preceded by two characters
Test_[0-9]UP_[a-z][a-z]_UNIT

if this doesn't help
try
Test.*



RE: "Regular Expression for my output" - suresz449 - 12-13-2011

Hi Ravi,

You are giving regular expression for 9 and ab but in my output sometimes the value may be 10,11,...... and ab,abc,abcd,azfdg,....... etc.these values are changing dynamically so, please provide the regular expression for given string.


RE: "Regular Expression for my output" - ravi.gajul - 12-13-2011

Well then .....Test.*...... should have helped.


RE: "Regular Expression for my output" - Ankesh - 12-13-2011

Hi Sures,

Can you try this..


Code:
strText="Test_101UP_abcde_UNIT"

Set RegEx = CreateObject("VBScript.RegExp")
'The below is the patter which can be used in your case
'\d{1,} - means any digit which will occur atleast once and may appear n times
'[a-z]{2,} - any two digit character to n length characted
'$ - indicates the end of the string

Code:
RegEx.Pattern ="^Test_\d{1,}UP_[a-z]{2,}_UNIT$"

result=RegEx.Test(strText)
If result=True Then
    msgbox "Pass"
Else
    msgbox "Fail"
End If

Set RegEx=Nothing

let me know if it works.

Regards,
Ankesh


RE: "Regular Expression for my output" - suresz449 - 12-16-2011

It's working good, Thanks Ankesh.


RE: "Regular Expression for my output" - Ankesh - 12-16-2011

Glad that it worked. Big Grin


RE: "Regular Expression for my output" - shivu.hanu - 12-27-2011

test_\[1-9][0-9].*up_\[a-z][a-z]_unit