Open
Description
I also propose to add a few other functions that can be commonly used.
-
Replace function, this can be implemented in several ways:
- First implementation: string.replace(pos , len, new_string)
- pos = starting position of the sub-string to be replaced.
- len = length of the substring
- new_string = the string that will replace the substring
- Second implementation: string.replace(pos, old_string, new_string)
- old_string = substring to be replaced.
- pos = position to start the search of old_string
- new_string = string that will replace old_substring
- This function will replace only the first occurrence of the old_string.
- Third implementation: string.replaceall(pos, old_string, new_string)
- This meaning of variables is similar to the second implementation.
- The difference is it will find and replace all the occurrences of old_string after pos and not just one.
- First implementation: string.replace(pos , len, new_string)
-
We already have an operator to Concat a string with another but I feel we should also implement a function for the same.
The community can have a discussion over the need for such functions and if needed also suggest some other implementation of Replace function.
Originally posted by @ChetanKarwa in #364 (comment)