Micro Focus QTP (UFT) Forums
Mail ID using Regular Expression - 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: Mail ID using Regular Expression (/Thread-Mail-ID-using-Regular-Expression)



Mail ID using Regular Expression - asisha - 03-09-2011

Hi all,

Can we control the number of characters through the regular expression
For example i want only 7 characters in first part of the mail id(before @ symbol)

How can we write the regular expression for that?

regards,
asisha


RE: Mail ID using Regular Expression - surya_7mar - 06-07-2011

Code:
Length(Split("someone@domain.com", "@")(0)) = 7



RE: Mail ID using Regular Expression - vIns - 06-07-2011

Hi..
Since you have asked this under Regular expression...We can do as given below...

Code:
Set myReg = New RegExp
myReg.Global = True
myReg.IgnoreCase = True

myReg.Pattern = "[a-z0-9]{2,7}@gmail.com" ' Here i just assumed that before @ we can have 2 min chars and max 7 chars. If u need 'to have only 7 then wirte like {7}

'returns true as no of chars 4
msgbox myReg.Test("test@gmail.com")

'returns false. as 1 char
msgbox myReg.Test("t@gmail.com")