Question: Without the regexpr() and gregexpr() functions, write a function called my_gregexpr() that inputs a character string pattern and a character vector text and returns a

Without the regexpr() and gregexpr() functions, write a function called my_gregexpr() that inputs a character string pattern and a character vector text and returns a list of the same length as text, each component of which is an integer vector giving the starting positions of every (disjoint) match of pattern in the corresponding entry in text or -1 if there is no match. The output values from my_gregexpr(pattern, text) and gregexpr(pattern, text) should be identical for any character string pattern and character vector text. Hint: Your my_gregexpr() function only needs to account for literal patterns, i.e., it does not need to work for regular expressions. Note: You do not need to add attributes to each component of the output list of my_gregexpr() to match gregexpr(). This will mean identical(my_gregexpr(pattern, text), gregexpr(pattern, text)) will always return FALSE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!