Global property is used to tell how many matches should be found in the given string.
Examples to understand the global property are given below.
'**********************************************
'With global = false
'When we set the global property to false, we get only first match
'**********************************************
Set regExpObject = New RegExp
search_string = "Arjun tendulkar is the son of sachin tendulkar"
regExpObject.Pattern = "tendulkar"
regExpObject.Global = false
set matches = regExpObject.execute(search_string)
print matches.count
'**********************************************
'output is 1
'**********************************************
'**********************************************
'With global = true
'When we set the global property to true, we get all matches
'**********************************************
Set regExpObject = New RegExp
search_string = "Arjun tendulkar is the son of sachin tendulkar"
regExpObject.Pattern = "tendulkar"
regExpObject.Global = true
set matches = regExpObject.execute(search_string)
print matches.count
'**********************************************
'output is 2
'**********************************************
You may also like below topics on regular expressions in QTP.
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.
Examples to understand the global property are given below.
'**********************************************
'With global = false
'When we set the global property to false, we get only first match
'**********************************************
Set regExpObject = New RegExp
search_string = "Arjun tendulkar is the son of sachin tendulkar"
regExpObject.Pattern = "tendulkar"
regExpObject.Global = false
set matches = regExpObject.execute(search_string)
print matches.count
'**********************************************
'output is 1
'**********************************************
'**********************************************
'With global = true
'When we set the global property to true, we get all matches
'**********************************************
Set regExpObject = New RegExp
search_string = "Arjun tendulkar is the son of sachin tendulkar"
regExpObject.Pattern = "tendulkar"
regExpObject.Global = true
set matches = regExpObject.execute(search_string)
print matches.count
'**********************************************
'output is 2
'**********************************************
You may also like below topics on regular expressions in QTP.
No comments:
Post a Comment
Please Leave your reply. We value your feedback and inputs