gensub stands for general substitution. It adds more features that are not available in the sub() and gsub() functions. With gensub(), we can specify the number of occurrences of the matched regular expression that is to be replaced. It returns the modified string as the result of executing the function, and the original string is not changed. Its syntax is as follows:
gensub ( regex for original-string, replacement-string, occurrence-number, [string] )
- regex for original-string: This is the original string that needs to be replaced. This can also be a regular expression.
- replacement-string: This is the new string that is to be used for substitution.
- Occurrence-number: This ...