in Technology by

regmatches(number, gregexpr(pattern = “2.?2”,text = number)) Is this an example of non-greedy quantifier? If yes, then why and what would be the equivalent greedy quantifier?

1 Answer

0 votes
by
No. This is an example of a non-greedy quantifier. An equivalent greedy approach would be – regmatches(number, gregexpr(pattern = "2.*2",text = number)) . Suppose that for a given number, val1 = 2020000200 The greedy approach would initiate from the first digit ‘2’. It then moves ahead and encounters the second digit ‘2’. It keeps searching for another ‘2’ digit which it also encounters. However, it does not find any more digits after that and hence, it returns the value: 20200002. A non-greedy approach on the other hand, stops at the first match and returns us the value of 202.

Related questions

0 votes
0 votes
0 votes
    Write pseudo code to count occurrence of a given number in the list. For example, consider the following list, if ... in the list. Select the correct answer from above options...
asked Nov 28, 2021 in Education by JackTerrance
0 votes
    If a current of 0.5A flows through a metallic wire for 2 hours, then how many electrons would flow through the wire ? Select the correct answer from above options...
asked Jan 5, 2022 in Education by JackTerrance
0 votes
    From a group of 3 boys and 2 girls, we select two children. What would be the sample space for this experiment ? Select the correct answer from above options...
asked Nov 15, 2021 in Education by JackTerrance
0 votes
    write a program to enter a sentence and check if it contains palindrome words or not. if yes then count and ... present. Java class 10 Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    A memory byte location contains the pattern 00101100. What does this pattern represent when interpreted as a binary ... ASCII code? Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    What would be the behaviour if this() and super() used in a method? (a) Runtime error (b) ... java programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    I have this code in php that I could not run in PHP 5.2.9 please give me an Idea to convert ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I have this code in php that I could not run in PHP 5.2.9 please give me an Idea to convert ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
0 votes
    If every non-key attribute is functionally dependent primary key, then the relation will be in (a) First ... , Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
...