Hi,
Use this Function.
strReturn=fMatch ("100000000","100")
'#########################################################################################################################
' FUNCTION NAME: fMatch
' CREATED BY: Byzoor
' DATE CREATED: 22/06/2010
' DESCRIPTION: This function finds the the first occurrence of a
regular expression in a string.
' PARAMETERS: Strng - The enclosing string
' RegularExpression - The expression to locate in the
string
' In addition, two Environment variables are assigned
values when the regular
' expression is found:
' RSTART gets the character position in the string at
which the regular expression
' starts. The first character of the string is
designated by 1.
' RLENGTH is assigned the length of the substring
matched by the RegularExpression.
' RETURNS: 0 when match is found, 1 if it is not have valid values
' Modification Log:
' Date Initials Modification
' ------------- ------------
----------------------------------------
'
'#########################################################################################################################
Public Function fMatch (Strng, RegularExpression)
Dim regEx, Matches 'Declare variables
'Reset values of RSTART and RLENGTH to default
Environment.Value("RSTART") = ""
Environment.Value("RLENGTH") = ""
Set regEx = New RegExp 'Create a new regular expression object
regEx.Pattern = RegularExpression 'Set pattern.
regEx.IgnoreCase = False 'Set case insensitivity: case sensitive
regEx.Global = False 'Set global applicability: pattern should match
only first occurrence of regexp in search string
If regEx.Test(Strng) Then 'If regular expression occurs
Set Matches = regEx.Execute(Strng) 'Execute search and create Matches
collection contains individual Match objects
'Because function will match only the first occurrence of regexp it will be
only one Match object in the Matches collection
Environment.Value("RSTART") = Matches(0).FirstIndex + 1
Environment.Value("RLENGTH") = Matches(0).Length
fMatch = 0 'Match is found
Set regEx = Nothing 'Discontinues association
Exit Function
End If 'If regEx.Test(Strng) Then
Set regEx = Nothing 'Discontinues association
fMatch = 1 'Match is not found
End Function
Happy Tester,
Byzoor,
On Wed, Jun 22, 2011 at 7:49 AM, Sandeep PL <[email protected]> wrote:
> Hi according to my knowledge
> (100) - - - - - -1[0-9]{2}, if first digit is any digit reg
> expression should be [1-9][0-9]{2}
> 100000000 -------- 1[0-9]{9}
>
>
>
> On Mon, Jun 20, 2011 at 10:38 AM, Sheik Adil <[email protected]> wrote:
>
>> Hi All,
>>
>> How to Regular Expressize
>> this (100)
>> (100000000)
>> Help me its Urgent
>> Thanks
>> Ad
>>
>> --
>> You received this message because you are subscribed to the Google
>> "QTP - HP Quick Test Professional - Automated Software Testing"
>> group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/MercuryQTP?hl=en
>
>
> --
> You received this message because you are subscribed to the Google
> "QTP - HP Quick Test Professional - Automated Software Testing"
> group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/MercuryQTP?hl=en
--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en